note 25956 deleted from function.shuffle by aidan

From: Date: Thu, 26 Aug 2004 22:34:27 +0000
Subject: note 25956 deleted from function.shuffle by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75371@lists.php.net to get a copy of this message
Note Submitter: digdan78 at hotmail dot com ---- Here is a quick and dirty way to shuffle associative arrays and not loose the key value relationship : function assc_shuffle($orig_array) { for($i=0;$i < count($orig_array);$i++) { $map[] = $i; } shuffle($map); foreach($map as $mk=>$mv) { $wait=0; foreach($orig_array as $ok=>$ov) { if ($mv == $wait) { $proc_array[$ok] = $ov; break; } $wait++; } } return $proc_array; } Hope this help someone out. Dan Morgan

« previous php.notes (#75371) next »