Blogger Information
Blog 28
fans 0
comment 0
visits 65353
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP生成随机数
蒸蒸
Original
667 people have browsed it

文章转自:https://blog.csdn.net/llfdhr/article/details/53330841

  1. //随机生成一个由16位数字组成的字符串
  2. function rand_num($num=16){
  3. $n=[];
  4. for($i=0;$i<$num;$i++){
  5. $n[$i] = $i;
  6. }
  7. for($i=0;$i<$num;$i++){
  8. $rand = mt_rand($i,$num-1);
  9. //数组 随机数交换下标
  10. if($n[$i] == $i){
  11. $n[$i] = $n[$rand];
  12. $n[$rand] = $i;
  13. }
  14. }
  15. //将数组转化为字符串返回
  16. $a=implode('',$n);
  17. return $a;
  18. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post