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 = []; for ($i = 1; $i <= 24; $i++) { $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] => 15 [1] => 14 [2] => 13 [3] => 17 [4] => 23 [5] => 8 [6] => 16 [7] => 18 [8] => 1 [9] => 22 [10] => 4 [11] => 12 [12] => 2 [13] => 20 [14] => 10 [15] => 6 [16] => 0 [17] => 7 [18] => 19 [19] => 11 [20] => 5 [21] => 3 [22] => 21 [23] => 9 )