Posted By

kayue on 12/31/10


Tagged


Versions (?)

Get variable name


 / Published in: PHP
 

  1. // http://www.laruence.com/2010/12/08/1716.html
  2.  
  3. function get_variable_name(&$var, $scope = NULL) {
  4. if (NULL == $scope) {
  5. $scope = $GLOBALS;
  6. }
  7.  
  8. $tmp = $var;
  9.  
  10. $var = "tmp_exists_" . mt_rand();
  11.  
  12. $name = array_search($var, $scope, TRUE);
  13.  
  14. $var = $tmp;
  15.  
  16. return $name;
  17. }
  18.  
  19.  

Report this snippet  

You need to login to post a comment.