I am trying to create a multi dimensional array using this syntax:
$x[1] = 'parent';
$x[1][] = 'child';
I get the error: [] operator not supported for strings
because it is evaluating the $x[1]
as a string as opposed to returning the array so I can append to it.
What is the correct syntax for doing it this way? The overall goal is to create this multidimensional array in an iteration that will append elements to a known index.
The syntax ${$x[1]}[]
does not work either.