3v4l.org

run code in 300+ PHP versions simultaneously
<?php function preserve_shuffle(&$arr) #Shuffles the key-value associations in an array. { $keys = array_keys($arr); #extract the keys from the array. shuffle($keys); $arr = array_merge(array_flip($keys), $arr); } $arr = ["a" => "apple", "b" => "banana", "c" => "capsicum", "d" => "dill"]; preserve_shuffle($arr); var_export($arr);

preferences:
25.02 ms | 408 KiB | 5 Q