php random x digit number

前端 未结 21 2152
耶瑟儿~
耶瑟儿~ 2020-12-04 15:00

I need to create a random number with x amount of digits.

So lets say x is 5, I need a number to be eg. 35562 If x is 3, then it would throw back something like; 463

21条回答
  •  天命终不由人
    2020-12-04 15:35

    you can generate any x-digit random number with mt_rand() function. mt_rand() much faster with rand() function syntax : mt_rand() or mt_rand($min , $max).

    read more

    example :

提交回复
热议问题