Return to Snippet

Revision: 9073
at October 20, 2008 17:30 by breakerjump


Initial Code
function shuffle_with_keys(&$array) { 
	$aux = array(); 
	$keys = array_keys($array); 
	shuffle($keys); 
	foreach($keys as $key) { 
		$aux[$key] = $array[$key]; 
		unset($array[$key]); 
	} 
	$array = $aux;
}

Initial URL
http://us3.php.net/manual/en/function.shuffle.php#83007

Initial Description

                                

Initial Title
Shuffle/Randomize Array while Preserving Keys

Initial Tags
array

Initial Language
PHP