/**
* 生成不重复的随机数
* @param int $start 需要生成的数字开始范围
* @param int $end 结束范围
* @param int $length 需要生成的随机数个数
* @return array 生成的随机数
*/
function rand_numbers($start=1,$end=10,$length=4){
$connt=0;
$temp=array();
while($connt<$length){
$temp[]=mt_rand($start,$end);
$data=array_unique($temp);
$connt=count($data);
}
sort($data);
return $data;
}
/*
保留键随机打乱数组顺序
*/
function retain_key_shuffle(array &$arr){
if (!empty($arr)) {
$key = array_keys($arr);
shuffle($key);
foreach ($key as $value) {
$arr2[$value] = $arr[$value];
}
$arr = $arr2;
}
}
//Demo
$rands=rand_numbers(0,200,12);
retain_key_shuffle($rands);
foreach($rands as $k=>$v){
echo $v."\r\n";
}
-
百度网盘 bdstoken 获取 3月 25, 2019
-
解决 Google Play文件过大,需要通过WLAN下载 的问题 12月 17, 2019
-
使用CloudFlare, 缓存所有文件 10月 17, 2018
-
宝塔面板 使用MongoDB一些教程 PHP7 3月 17, 2019
-
怎么获取Telegram私人电报频道的ID 11月 18, 2019
-
php如何处理wsdl,SOAP协议的请求 6月 29, 2022
-
如何将PHP数组的所有值更改为大写或小写 6月 21, 2022
-
Nginx 反向代理规则 6月 12, 2022
-
Livewire.js 404 的问题的处理思路和解决方式 6月 12, 2022
-
小A on Google Voice API 接口
-
宝塔面板降级安装教程,降级到7.7.0 不绑定宝塔账号安装 – 阳'Blog on 宝塔面板BT Panel弹窗强制绑定宝塔账号关闭解除教程
[…] (...)
-
怎么联系你 on Google Voice API 接口
-
Conan on Google Voice API 接口
-
Conan on Google Voice API 接口