Hello
First time here, noob in php, hope to learn ?
$foo = “bar”;
$myArray[$foo] = array();
This will work.
$foo = “bar”;
$anotherFoo = “blah”;
$myArray[$foo][$anotherFoo] = array ();
This also.
$myArray[$key1][$key2][$key3][… and so on] = array ();
So everythin following this pattern also will work.
Now assume I have a multidimensional associative array.
How to store each key of the path as one variable ie:
$foo = “$key1][$key2][$key3”;
$myArray[$foo] = array ();
I managed to achieve this by using eval() but I know that is a bad way to go:
$foo = “$key1][$key2][$key3”;
$execute = ‘$myArray[‘.$foo.’] = array ();’;
eval ($execute);
Question is: how to achieve same thing without eval () ?
I want to acces a multiarray by ‘array key paths’ stored in variables, when I don’t know how deep I will go (so I can’t use a pattern).
I will be very grateful for any help.