PHPで80以内に10個ランダムな数を取得して、配列を生成する

PHPコード:
<?php
function get_randoms($min,$max,$num){
$count = 0;
$res = array();
while($count<$num){
$key = mt_random($min,$max);
$res[$key] = $key;
$count = count($res);
}
return $res;
}

$result = get_randoms(1,80,10);
?>

説明:
int mt_rand ( int $min , int $max )
乱数値を生成する

PHP

Posted by arkgame