note 33685 added to function.array-rand

From: Date: Thu, 03 Jul 2003 20:34:22 +0000
Subject: note 33685 added to function.array-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-51484@lists.php.net to get a copy of this message
The shuffle() routine works great, far better than array_rand(). Just one small change I'd make, as mt_rand(0, 0) doesn't work: $c = count($foo); for ($i=1; $i<$c; $i++) {    $d = mt_rand(0, $i);    $tmp = $foo[$i];    $foo[$i] = $foo[$d];    $foo[$d] = $tmp; } ---- Manual Page -- http://www.php.net/manual/en/function.array-rand.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33685 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33685&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33685&report=yes

« previous php.notes (#51484) next »