note 9699 modified in Variable variables by jeroen
| From: | jeroen@php.net | Date: | Thu, 24 May 2001 00:20:41 +0000 |
| Subject: | note 9699 modified in Variable variables by jeroen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14235@lists.php.net to get a copy of this message | ||
[Editors note:
This doesn't work, because you try to assign a value to the variable named 'a[0]'. If
you want this kind of behaviour (execute PHP-syntax out of strings), take a look at eval()
]
You can't create an array using variable variables!
example:
$n="a"
$$n=12
echo($a);
this will work, hence, $a = 12;
however,
$n="a[0]";
$$n=12;
$n="a[1]";
$$n=24;
echo(count($a).",".$a[0].",".$a[1]);
I expected the output to be: 2,12,24
However, actually this output nothing but three ","s.
http://www.php.net/manual/variable-variables.php