Using a variable to call another variable
| From: | Dave M G | Date: | Sat, 09 Sep 2006 03:57:24 +0000 |
| Subject: | Using a variable to call another variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-241518@lists.php.net to get a copy of this message | ||
PHP List,
I have a list of variables:
$001
$002
$003
$004
And what I'd like to do is have a function which will select and return one of them. Something like:
public function returnVar($n)
{
return $(somehow n is made to reference the name of the variable);
}
And then in later scripts I can call anyone of the variables by saying
returnVar(001)
Or something like that.
I've been scratching my head on how to do this for a while. I thought the answer might lie somewhere in call_user_func(), but even if it is I can't determine how.
Any advice would be much appreciated.
Thank you for your time.
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2