3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $nums = []; for ($i = 1; $i <= 24; $i++) { $nums[] = $i; } print_r($nums); $days = []; foreach ($nums as $num) { $day = array_rand($nums); $days[] = $day; unset($nums[$day]); } print_r($nums); print_r($days);
Output for 7.1.23
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] => 16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 [20] => 21 [21] => 22 [22] => 23 [23] => 24 ) Array ( ) Array ( [0] => 3 [1] => 13 [2] => 21 [3] => 23 [4] => 18 [5] => 9 [6] => 17 [7] => 20 [8] => 12 [9] => 10 [10] => 22 [11] => 2 [12] => 11 [13] => 4 [14] => 1 [15] => 8 [16] => 14 [17] => 5 [18] => 7 [19] => 0 [20] => 19 [21] => 16 [22] => 15 [23] => 6 )