note 110170 deleted from function.shuffle by googleguy
| From: | googleguy@php.net | Date: | Wed, 26 Sep 2012 04:14:42 +0000 |
| Subject: | note 110170 deleted from function.shuffle by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191029@lists.php.net to get a copy of this message | ||
Note Submitter: chris dot chaudruc at gmail dot com
----
I was having a hard time with most of the answers provided - so I created this little snippet that
took my arrays and randomized them while maintaining their keys:
function assoc_array_shuffle($array)
{
$orig = array_flip($array);
shuffle($array);
foreach($array AS $key=>$n)
{
$data[$n] = $orig[$n];
}
return array_flip($data);
}