This is a PHP Function to get the name of the variable (not the value) :
function getvarname(&$var)
{
$ret = ”;
$tmp = $var;
$var = md5(uniqid(rand(), TRUE));
$key = array_keys($GLOBALS);
foreach ( $key as $k )
if ( $GLOBALS[$k] === $var )
{
$ret = $k;
break;
}
$var = $tmp;
return $ret;
}
$another = ‘test’;
$testvar = ‘test’;
echo getvarname($testvar); //echoes ‘testvar’
?>

Twitter
LinkedIn