How do I select 10 random things from a list in PHP?

You could shuffle the array and then pick the first ten elements with array_slice:

shuffle($array);
$tenRandomElements = array_slice($array, 0, 10);

Leave a Comment