[PHP] How generate unique randoms
Hi my friends.
Today i will show u how generate unique random integer on php...
This is oru function to suffle our numbers.. For randomize :)
function UniqueRandom($min, $max, $leng) {How it use:
$numbers= range($min, $max);
shuffle($numbers);
return array_slice($numbers, 0, $leng);
}
<?php
print_r( UniqueRandom(0,25,5) );
?>
OutPut:
Array ( [0] => 12 [1] => 19 [2] => 5 [3] => 22 [4] => 3
)
And you can use that code like that:
<?php
$numbers=UniqueRandom(0,25,5);
echo numbers[0];
echo $numbers[3];
?>
0 comments: