- microtime: documentation ( source)
- mt_rand: documentation ( source)
- array_keys: documentation ( source)
<?php
$tstart = microtime(true);
$numberOfRandoms = 500;
$uniques = array();
do {
$uniques[mt_rand(10000, 99999)] = true;
} while(count(array_keys($uniques)) < $numberOfRandoms);
$uniques = array_keys($uniques);
$elapsed = $tstart - $start;
echo $elapsed . PHP_EOL;