note 76245 deleted from language.variables by googleguy
| From: | googleguy@php.net | Date: | Mon, 11 Feb 2013 05:17:43 +0000 |
| Subject: | note 76245 deleted from language.variables by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193592@lists.php.net to get a copy of this message | ||
Note Submitter: alexandre at nospam dot gaigalas dot net
----
Here's a simple solution for retrieving the variable name, based on the lucas
(http://www.php.net/manual/en/language.variables.php#49997) solution, but shorter, just two lines =)
<?php
function var_name(&$var, $scope=0)
{
$old = $var;
if (($key = array_search($var = 'unique'.rand().'value', !$scope ? $GLOBALS
: $scope)) && $var = $old) return $key;
}
?>