I'm trying to use a nested php array grabbed from a database in a loop to create a bunch of html elements.
Below is a cleaned up section of that code which still contains the strange error: non-nested arrays can be used properly, as in the code below:
<?php
$array = array();
$array[] = "a";
$array[] = "b";
$array[] = "c";
$x = 1;
echo "<input type='radio' value=\" $array[$x] \" id='$x'> <label for=\" $array[$x] \">" . $array[$x] . "</label><br>";
?>
But not when the array is nested, as here:
<?php
$subarray = array();
$subarray[] = "a";
$subarray[] = "b";
$subarray[] = "c";
$array = array();
$array[] = $subarray;
$subarray[] = "p";
$subarray[] = "q";
$subarray[] = "r";
$array[] = $subarray;
$x = 1;
echo "<input type='radio' value=\" $array[$x][$] \" id='$x'> <label for=\" $array[$x][1] \">" . $array[$x][1] . "</label><br>";
?>
For some strange reason, the "$array[$x][$x]" and "$array[$x][1]" only work outside of the "<>"-tags and brings about the "b" stored in the array at [1][1]. But within the "<>"-tags they only show as "Array[1]" in the inspector. The "$x" works fine within the "<>"-tags.
What can I do to make this work?
Thanks!