Easier way to get the name of a variable?

From: Date: Tue, 15 Aug 2006 18:19:49 +0000
Subject: Easier way to get the name of a variable?
Groups: php.general 
Request: Send a blank email to php-general+get-240720@lists.php.net to get a copy of this message
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. <?php function vname(&$var, $scope=false, $prefix='unique', $suffix='value') { if($scope) $vals = $scope; else $vals = $GLOBALS; $old = $var; $var = $new = $prefix.rand().$suffix; $vname = FALSE; foreach($vals as $key => $val) { if($val === $new) $vname = $key; } $var = $old; return $vname; } ?> Anyone aware of a simple language construct(?) that can do this? I'm on PHP 4.3.9. Thanks, Chris.

« previous php.general (#240720) next »