<?php
class Arr{
/**
* Перемешать ассоциативный массив в случайном порядке
*
* @param array $arr
*
* @return array
*/
public static function shuffle_assoc(array $arr)
{
$keys = array_keys($arr);
shuffle($keys);
$result = array();
foreach ($keys as $key)
{
$result[$key] = $arr[$key];
}
return $result;
}
}
Last active
October 3, 2015 09:07
-
-
Save DKepov/c3f5618e49c0e88f6ae5 to your computer and use it in GitHub Desktop.
shuffle assoc array
Author
DKepov
commented
Aug 31, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment