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