PHP之生成随机数

来源:互联网 发布:关系数据库设计范式 编辑:程序博客网 时间:2024/06/01 14:12

1.range() 函数创建一个包含指定范围的元素的数组。shuffle() 函数把数组中的元素按随机顺序重新排列。

$arr=array();$arr=range(1,100);shuffle($arr);

2.rand() 函数返回随机整数。array_unique()去重复

  while (count($arr)<100) {     $arr[]=rand(1,1000);     $arr=array_unique($arrr);  }
0 0