note 40267 deleted from function.shuffle by bjori

From: Date: Tue, 06 Jun 2006 21:33:54 +0000
Subject: note 40267 deleted from function.shuffle by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-113382@lists.php.net to get a copy of this message
Note Submitter: Justin Knoll ---- Benton, Thanks for the corrections. The for loop is corrected in your code, but I believe you overlooked changing my error in the call to mt_rand() ($i, not $i+1). Below is your version with that trivial change: function fisherYatesShuffle(&$array) { for ($i = 0; $i<count($array); $i++) { $j = @mt_rand(0, $i); $temp = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $temp; } }

« previous php.notes (#113382) next »