Computer >> Computer tutorials >  >> Programming >> PHP

gmp_random_range() function in PHP


The gmp_random_range() function is used to generate a random number. The number displayed is between the range you need to set in the function as parameters.

Syntax

gmp_random_range ( GMP $min_range, GMP $max_range )

Parameters

  • min_range − The minimum range for the random number.

  • max_range − The maximum range for the random number.

Return

The gmp_random_range()function returns the random GMP number in the range min_range to max_range.

Example

The following is an example −

<?php
   $min_range = "10";
   $max_range = "50";
   $rand_num = gmp_random_range($min_range, $max_range);
   echo $rand_num;
?>

Output

The following is the output −

17