note 57068 added to function.shuffle

From: Date: Thu, 22 Sep 2005 16:45:55 +0000
Subject: note 57068 added to function.shuffle
Groups: php.notes 
Request: Send a blank email to php-notes+get-95624@lists.php.net to get a copy of this message
Just a quick note to let people know that shuffle() will work on multidimensional associative arrays provided that the first key is already numeric. So this array can be shuffled without losing any of the secondary keys or their values: $array[0]['color'], $array[0]['size'], $array[0]['fabric'] . . . $array[50]['color'], $array[50]['size'], $array[50]['fabric'] I recently ran up against needing to randomize this array and tried shuffle even though it's not really for associative arrays. Hope it helps somebody out there. ---- Manual Page -- http://www.php.net/manual/en/function.shuffle.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57068 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57068&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57068&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95624) next »