Is it possible to assign variable values to keys while making a multidimensional array? For example:
//creates array
$arr = array(
'First' => array(),
'Second' => array()
);
//assigns strings to variables
$name = 'First';
$once = 'Name';
$twice = 'Age';
$thrice = 'Whatever';
//loops twice to create arrays
do {
$arr[$name][] = $once => array(), $twice => array(), $thrice => array();
$once = 'Another';
$twice = 'Example';
$thrice = 'You get the point';
if ($name == 'First') {
$name = 'Second';
} else {
$name = 'end';
}
} while ($name == 'Second');
The above example hardly makes sense to a living thing, let alone a piece of metal on my desk. If the above cannot be done with variables, how else could I create a multidimensional array with keys without explicitly coding it all out? Thanks in advance.
EDIT: To clarify, here's a sample call to the array I'd like to make:
echo $arr['Second']['Another'][2];
The third dimensional part of the array would be assigned with a loop not included, i.e., the 2. I'm having difficulty creating the second dimension is all.