This should work:
$total = count($emails);
$select = 5;
$numbers = array();
while (count($numbers) < $select) {
$num = mt_rand(1, $total);
if (!in_array($num, $numbers)) {
$numbers[] = $num;
}
}
foreach ($numbers as $value) {
send_email($emails[$numbers[$value]]);
}
Edit: Arrays start at 0 index (I forgot :o ). Replace this:
$num = mt_rand(1, $total);
with this:
$num = mt_rand(0, $total - 1);