Question on variable variables
| From: | Jeff Lewis | Date: | Sat, 17 Nov 2001 02:47:12 +0000 |
| Subject: | Question on variable variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-74957@lists.php.net to get a copy of this message | ||
I've a question regarding variable variable I was hoping someone could help me with:
All the examples in the manual have the entire variable name being variable e.g.
$a = "hello" and
$$a being the same as $hello
What I need to do, however, is append a variable portion to a constant prefix. So I have a set of
variables that are named $MYdog, $MYcat etc. and I need to do
$a = "dog"
${"MY$a"} being the same as $MYdog
Can this be done, and if so - how? I can't get it to work.
Jeff