- array_map: documentation ( source)
- var_dump: documentation ( source)
- sort: documentation ( source)
- in_array: documentation ( source)
- array_fill: documentation ( source)
- rand: documentation ( source)
<?php
$uniqueNumbers = 100;
$picked = [];
$randoms = array_map(function () use(&$picked, $uniqueNumbers) {
do {
$rand = rand(0, $uniqueNumbers);
} while(in_array($rand, $picked));
$picked[] = $rand;
return $rand;
}, array_fill(0, $uniqueNumbers, null));
sort($randoms);
var_dump($randoms);