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