note 22137 deleted from function.shuffle by irchtml
| From: | irchtml@php.net | Date: | Wed, 07 Apr 2004 06:35:53 +0000 |
| Subject: | note 22137 deleted from function.shuffle by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67745@lists.php.net to get a copy of this message | ||
Note Submitter: david[dont_spam_me]@boeke.com
----
If you are using php 4.2 and up this one liner should do the trick:
for($c=count($arr); $c>0; $r=@mt_rand(0,$c--))
array_splice($arr,$r,$c-$r,array_reverse(array_slice($arr,$r,$c-$r)));