note 33685 deleted from function.array-rand by aidan
| From: | aidan@php.net | Date: | Tue, 18 Oct 2005 05:28:52 +0000 |
| Subject: | note 33685 deleted from function.array-rand by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-97134@lists.php.net to get a copy of this message | ||
Note Submitter: rick at op8 dot com
----
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:
<?php
$c = count($foo);
for ($i=1; $i<$c; $i++) {
$d = mt_rand(0, $i);
$tmp = $foo[$i];
$foo[$i] = $foo[$d];
$foo[$d] = $tmp;
}
?>