note 110170 added to function.shuffle
| From: | chris dot chaudruc at gmail dot com | Date: | Wed, 26 Sep 2012 03:34:02 +0000 |
| Subject: | note 110170 added to function.shuffle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191027@lists.php.net to get a copy of this message | ||
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);
}
----
Server IP: 69.147.83.199
Probable Submitter: 24.14.34.176
----
Manual Page -- http://www.php.net/manual/en/function.shuffle.php
Edit -- https://master.php.net/note/edit/110170
Del: integrated -- https://master.php.net/note/delete/110170/integrated
Del: useless -- https://master.php.net/note/delete/110170/useless
Del: bad code -- https://master.php.net/note/delete/110170/bad+code
Del: spam -- https://master.php.net/note/delete/110170/spam
Del: non-english -- https://master.php.net/note/delete/110170/non-english
Del: in docs -- https://master.php.net/note/delete/110170/in+docs
Del: other reasons-- https://master.php.net/note/delete/110170
Reject -- https://master.php.net/note/reject/110170
Search -- https://master.php.net/manage/user-notes.php