- var_dump: documentation ( source)
- array_rand: documentation ( source)
- range: documentation ( source)
<?php
$t = range(1, 32, 1);
$g = [];
while (!empty($t) && count($g) < 4) {
$key = array_rand($t);
$g[] = $t[$key];
unset($t[$key]);
}
var_dump($g);
var_dump($t);