PHP mt_rand() function
This function is used to return random integer. This function is based on Mersenne Twister Random Number Generator algorithm. mt_rand() method is a replacement of rand() method. This method is four times faster than rand function.
Syntax
mt_rand(min, max);
min and max are lowest and highest value to be returned. By default both are optional parameters.
Example 1
<?php
echo mt_rand().'<br/>';
echo mt_rand().'<br/>';
?>
Output -
11399334821299210441
Example 2
If you want a random integer between 1 to 1000, pass these values as parameters in mt_rand().
<?php
echo mt_rand('1', '1000').'<br/>';
?>
Output -
4Related PHP Functions
PHP array_reverse() functionPHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function