what is the php function to randomize the associative array while keeping key/values pairs. I don\'t mean to just randomly pick out a key value pair, but actually changing the
You could use shuffle() on array_keys, then loop around your array adding them to the list in the new order.
E.g.
$shuffleKeys = array_keys($array);
shuffle($shuffleKeys);
$newArray = array();
foreach($shuffleKeys as $key) {
$newArray[$key] = $array[$key];
}
A comment on shuffle() might do the trick: http://ch2.php.net/manual/en/function.shuffle.php#104430
<?php
function shuffle_assoc( $array )
{
$keys = array_keys( $array );
shuffle( $keys );
return array_merge( array_flip( $keys ) , $array );
}
?>