Variable Variables and Mulitdimensional Arrays
| From: | Charlie Killian | Date: | Fri, 15 Mar 2002 18:15:26 +0000 |
| Subject: | Variable Variables and Mulitdimensional Arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-88688@lists.php.net to get a copy of this message | ||
Hi. I want to be able to access a key in a multidimensional array at some
depth "n" without knowing before runtime what the keys are.
I thought this might be possible using variable variables. Here's some
sample code using variable variables and multidimensional arrays:
$y = 'a';
$z = 'b';
$t = 'c';
$x = array("a"=>array("b"=>array("c"=>TRUE)));
print_r($x{$y}{$z}{$t}); // Prints 1.
// I want to be able to concatenate the array indexes into one variable
variable. This would be done in a loop at runtime.
$u = ${$y.$z.$t};
print_r($x{$u}); // Doesn't work.
Any help would greatly be appreciated,
Charlie