摘要:这篇文章主要介绍了php中实现获取随机数组列表的自定义函数,本文直接给出实现代码,需要的朋友可以参考下function create_random_ids( $min,$max,$limited ) { $_base_ids = range($min,$max); $_temp_key =&
这篇文章主要介绍了php中实现获取随机数组列表的自定义函数,本文直接给出实现代码,需要的朋友可以参考下
function create_random_ids( $min,$max,$limited )
{
$_base_ids = range($min,$max);
$_temp_key = array_rand ($_base_ids,min(count($_base_ids),$limited+10));
//拼接
$ids = array();
for ($x=0; $x < count($_temp_key); $x++) {
$ids[] = $_base_ids[$_temp_key[$x]];
}
return $ids;
}更多关于php中实现获取随机数组列表的自定义函数请关注PHP中文网(www.php.cn)其他文章!