note 21709 added to function.shuffle

From: Date: Thu, 23 May 2002 21:43:31 +0000
Subject: note 21709 added to function.shuffle
Groups: php.notes 
Request: Send a blank email to php-notes+get-30959@lists.php.net to get a copy of this message
Forget shuffle, this function will work well .... function ShuffleArray($array) // or &$array by reference { srand ((double) microtime() * 10000000); $caa=(count($array)-1); $new_array=$array; for ($x=0;$x<=$caa;$x++) { $ca=(count($array)-1); $i=rand(0,$ca); $new_array[$x]=$array[$i]; for ($t=$i;$t<$ca;$t++) $array[$t]=$array[$t+1]; array_pop($array); } return $new_array; by reference not needed } -- http://www.php.net/manual/en/function.shuffle.php http://master.php.net/manage/user-notes.php?action=edit+21709 http://master.php.net/manage/user-notes.php?action=delete+21709 http://master.php.net/manage/user-notes.php?action=reject+21709

« previous php.notes (#30959) next »