<?php
function array_rand_fill($length, $max)
{
$result = array();
if ($max < $length)
;
elseif ($max == $length)
{
for ($i = 0; $i < $length; $i++)
$result[] = $i;
shuffle($result);
return $result;
}
else
{
for ($i = 0; $i < $length; $i++)
{
do {
$generated_value = mt_rand(0, $max);
} while (in_array($generated_value, $result));
$result[] = $generated_value;
}
}
return $result;
}
print_r(array_rand_fill(100, 100));// shuffle()
print_r(array_rand_fill(100, 200));
print_r(array_rand_fill(200, 100));// array()