Re: variable names

From: Date: Tue, 14 Nov 2000 22:58:35 +0000
Subject: Re: variable names
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25267@lists.php.net to get a copy of this message
your proposal isn't really sophisticated :) if you could get the pointer of the variable it would have been the key to find the variable. Eric ----- Original Message ----- From: "Matt McClanahan" <cardinal@dodds.net> To: "Jan-Eric Duden" <jeduden@whisset.com> Cc: <php-general@lists.php.net> Sent: Tuesday, November 14, 2000 3:40 PM Subject: Re: [PHP] variable names > 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 > >

« previous php.general (#25267) next »