note 12857 deleted from function.shuffle by aidan

From: Date: Thu, 26 Aug 2004 22:34:30 +0000
Subject: note 12857 deleted from function.shuffle by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75374@lists.php.net to get a copy of this message
Note Submitter: rze at counter-strike dot net ---- Shuffle didn't work well at all, for me. I seeded it and it still wasn't random. I wrote my own function below, it seems to work better, for me: function array_rand_elim (&$array1, $array2 = array ()) { if (!count ($array1)) return array1; srand ((double) microtime() * 10000000); $rand = array_rand ($array1); $array2[] = $array1[$rand]; unset ($array1[$rand]); return $array2 + array_rand_elim ($array1, $array2); } $array = array_rand_elim ($array);

« previous php.notes (#75374) next »