Re: variable names
| From: | Matt McClanahan | Date: | Tue, 14 Nov 2000 22:40:49 +0000 |
| Subject: | Re: variable names | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25266@lists.php.net to get a copy of this message | ||
On Tue, 14 Nov 2000, Jan-Eric Duden wrote:
> Does anybody know if there is a function that returns the name of variable?
> I imagine something like this:
>
> $myvar="bla";
> $name=GetVarName($myvar);
>
> $name=="myvar"
There isn't really a function to do this that I know of. One (messy)
option could be to search $GLOBALS, but it'd be highly prone to being
unreliable. I probably wouldn't suggest using it, just thinking outloud.
$myvar = 'blah'
foreach ($GLOBALS as $key => $val)
{
if ($val == $myvar)
echo "Variable match: $key\n";
}
Matt