3v4l.org

run code in 300+ PHP versions simultaneously
<?php $maxId = 10; $n = 10; // If there are less urls in the db then required, lower the requirements $n = $maxId < $n ? $maxId : $n; $randomIds = []; while (count($randomIds) < $n) { $randomId = rand(1, $maxId); if (!in_array($randomId, $randomIds)) { $randomIds[] = $randomId; } } var_dump($randomIds);

preferences:
33.32 ms | 402 KiB | 5 Q