Re: Need key() equivalent for string variable
| From: | Richard Lynch | Date: | Mon, 22 Jan 2001 22:26:49 +0000 |
| Subject: | Re: Need key() equivalent for string variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36105@lists.php.net to get a copy of this message | ||
> I'm trying to pass a string variable to a custom function, echoing its
> *value on one line, and its *name (that is, its key if this were an array
I think you are looking for "variable variables"...
<?php
$foo = 'test';
$test = 42;
echo "$foo is ", $$foo, "<BR>\n";
?>
Note the use of $$ to sort of "follow the trail" down to a variable.
Don't miss the Zend Web Store's Grand Opening on January 23, 2001!
http://www.zend.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm