note 54460 added to function.shuffle
| From: | anders dot carlsson at sfks dot se | Date: | Tue, 05 Jul 2005 09:17:08 +0000 |
| Subject: | note 54460 added to function.shuffle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91462@lists.php.net to get a copy of this message | ||
Vladimir's routine to sort an associated array is great, but one may want to add a clause to
check that the array is not empty:
if (count($shuffle_me)>0) { code }
This is because array_rand does not like to pick zero entries out of an empty array (at least not in
PHP 4.x).
----
Manual Page -- http://www.php.net/manual/en/function.shuffle.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54460
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54460&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54460&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54460&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54460&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54460&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54460&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54460&report=yes
Search -- http://master.php.net/manage/user-notes.php