PHP.nl

gmp_random_range

gmp_random_range

Get a uniformly selected integer

GMP **gmp_random_range**  $min  $max

Generate a random number. The number will be between and . min``max

and  can both be negative,

but must always be less than . min``max``min``max

minA GMP number representing the lower bound for the random number

maxA GMP number representing the upper bound for the random number

Returns a object which contains a uniformly selected integer from the closed interval [, ]. Both and are possible return values. GMP``min``max``min``max

If is less than , a will be thrown. max``min

Voorbeeld: example

<?php
$rand1 = gmp_random_range(0, 100);    // random number between 0 and 100
$rand2 = gmp_random_range(-100, -10); // random number between -100 and -10

echo gmp_strval($rand1) . "\n";
echo gmp_strval($rand2) . "\n";
?>
42
-67