Re: Easier way to get the name of a variable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris W. Parker wrote:
> Hello,
> 
> After some "intense" searching of Google I found one example at
> http://us2.php.net/language.variables on how to get the name of a
> variable. But it looks pretty expensive.
> 
> <snip>
> 
> Anyone aware of a simple language construct(?) that can do this? I'm on
> PHP 4.3.9.
> 

get_defined_vars() can get you a list of all the currently defined
variables.  If you have the value of the variable, you can use
array_search() to find the (first) key.

I do have some misgivings about what you are trying to do though.  I
can't see a case where this would be the best way to solve a problem.


David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux