Reply to Re: getting the variable name in php

Your name:

Reply:


Posted by Ewoud Dronkert on 06/02/05 16:08

On Thu, 02 Jun 2005 13:09:31 +0100, James wrote:
> Someone has wrote some info on how to do this here, as a user
> contributed note: http://php.net/variables
> [...] credit goes to lucas karisny.

Yeah. If you have no need for local scope you can trim the function a
little. Also with simpler unique value generation:

function f( &$x )
{
$old = $x;
$x = md5( uniqid( mt_rand(), TRUE ) );
foreach ( $GLOBALS as $k => $v )
if ( $v === $x )
{
$x = $old;
return $k;
}
return FALSE;
}

$a = 'test';
$b = 'test';
echo f( $a ); // 'a'
echo f( $b ); // 'b'


--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация