This seems to do reasonably well as a shuffle() that preserves index assocation:
<?php
function ashuffle (&$arr) {
uasort($arr, function ($a, $b) {
return rand(-1, 1);
});
}
?>
Obviously only works if PHP has closures enabled...
This seems to do reasonably well as a shuffle() that preserves index assocation:
<?php
function ashuffle (&$arr) {
uasort($arr, function ($a, $b) {
return rand(-1, 1);
});
}
?>
Obviously only works if PHP has closures enabled...