note 9117 deleted from function.array-flip by irc-html

From: Date: Sat, 19 Jan 2002 21:01:24 +0000
Subject: note 9117 deleted from function.array-flip by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25456@lists.php.net to get a copy of this message
if you're a bit more of a purist about your random values, try the following algortithm. note: for reasons that should be obvious, this is only useful if you're using the array like a stack or a queue (ie; it's indexed, and the actual value of the indices don't matter), but for me this seems to be most of the time. <? mt_srand((double)microtime()*1000000); $bob=array_flip($bob); while (list($key,$val)=each($bob)) { $bob[$key]=mt_rand(); } $bob=array_flip($bob); #we now have an array with highly random indices ksort($bob); ?>

« previous php.notes (#25456) next »