php array_rand()函数从数组中随机选择一个或多个元素

2020-11-15 11:23

阅读:810

标签:com   http   class   blog   style   div   code   tar   log   color   get   

php使用array_rand()函数从数组中随机选择一个或多个元素的方法。
使用array_rand() 函数从数组中随机选出一个或多个元素,并返回。 
array_rand(array,number) 
参数 描述 
array 必需。规定输入的数组参数。 www.jbxue.com
number 可选。默认是 1。规定返回多少个随机的元素。 
例子: 
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); 
print_r(array_rand($a,1)); 
?> 
结果:
b

php array_rand()函数从数组中随机选择一个或多个元素,布布扣,bubuko.com

php array_rand()函数从数组中随机选择一个或多个元素

标签:com   http   class   blog   style   div   code   tar   log   color   get   

原文地址:http://www.cnblogs.com/linuxnotes/p/3698394.html


评论


亲,登录后才可以留言!