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]
|