An php code for generating 16 bit random numbers of two methods

  • 2021-07-18 07:41:05
  • OfStack

Share 1 code for php to generate 16-bit random numbers and 2 methods for php to generate random numbers.

Method 1


<?php
$a = mt_rand(10000000,99999999);
$b = mt_rand(10000000,99999999);
echo $a.$b;

Method 2:


<?php
$a = range(0,9);
for($i=0;$i<16;$i++){
$b[] = array_rand($a);
} // www.yuju100.com
var_dump(join("",$b));
// Results string(16) "0179571910024734"


Related articles: