Source Code:
(back to article)
<?php $person = ["name" => "John", "age" => 30, "city" => "New York"]; // Shuffle the keys of the array $keys = array_keys($person); shuffle($keys); // Create a new array with the shuffled keys $shuffled_person = []; foreach ($keys as $key) { $shuffled_person[$key] = $person[$key]; } print_r($shuffled_person);
Result:
Report an issue