creating array on variable variable (bug?)
| From: | Tobias Talltorp | Date: | Fri, 16 Mar 2001 00:14:45 +0000 |
| Subject: | creating array on variable variable (bug?) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-44173@lists.php.net to get a copy of this message | ||
Hello all.
Howcome I can create an array on a variable variable using array(), but not
in a for-loop (See code below)?
<?
$name = "talltorp";
$$name = array(1,2,3,4); // <-- this works
for ($i=0; $i<10; $i++) { //
$$name[] = $i; // <-- this does not work
} //
for ($i=0; $i<sizeof($talltorp); $i++)
echo $talltorp[$i];
}
?>
In the for-loop I get this error message:
Fatal error: Cannot use [] for reading in
E:\Inetpub\wwwroot\testscript\sessions\test4.php on line 6
Is this a bug or do I have the bugs in my head finally gotten to my thinking
area?
Thanks,
// Tobias Talltorp