dynamic variable arrays?
| From: | Hans H. Anderson | Date: | Thu, 07 Dec 2000 21:02:25 +0000 |
| Subject: | dynamic variable arrays? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-29212@lists.php.net to get a copy of this message | ||
I'm trying to get this to work, so I can build dynamic, multidimensional
arrays. It fails to output anything, though. Is this just not
possible? If so, is there any way to have dynamic dimensions of arrays?
<?php
$s = array("hans","brent","annie");
$x = "comp";
for($i=0;$i<sizeof($s);$i++) {
$x .= "[\"" . trim($s[$i]) . "\"]";
}
$$x = "hello, world!";
print $comp["hans"]["brent"]["annie"];
?>
I'm hoping to get hello, world! out of that print at the end, but to no
avail.
Basically what I am trying to do is have a method for assigning dimensions
to arrays dynamically... I won't know how many dimensions there might need
to be ahead of time.
Thanks in advance,
--
Hans Anderson -=- me@hansanderson.com
http://www.hansanderson.com | PHP, SQL Databases, Flash 5
Animation &
http://www.goofiness.com | Programming, Audio Production,
Brewmeister.