- var_dump: documentation ( source)
- in_array: documentation ( source)
- rand: documentation ( source)
<?php
$uniqueIds = [];
while(count($uniqueIds) < 5) {
$randomNumber = rand(1000, 9999);
if (!in_array($randomNumber, $uniqueIds)) {
$uniqueIds[] = $randomNumber;
}
}
var_dump($uniqueIds);