Re: retriving a variable name
| From: | Chris Shiflett | Date: | Tue, 22 Oct 2002 04:21:21 +0000 |
| Subject: | Re: retriving a variable name | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120853@lists.php.net to get a copy of this message | ||
It sounds like you're asking two different questions here, but try this sample code for a possible answer to one:
<?
$var_name="foo";
$$var_name="bar";
echo $foo;
?>
Happy hacking.
Chris
Matt Giddings wrote:
Is there a way to retrieve the variable name from within php? Example: $myvar = 'test'; I want to be able to pass '$myvar' to a function and retrieve both the name of the variable 'myvar' and the value of the variable 'test' in this case.