Blogger Information
Blog 250
fans 3
comment 0
visits 321882
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组函数:array_rand()的作用和方法
梁凯达的博客
Original
1466 people have browsed it

//array_rand()
//函数用于随机取出数组的键名(下标)
//参数包含了:array_rand($要随机的数组,参数2[随机几个数?])
//函数的返回值为随机得到结果的一个数
 
 

实例

$arr_red = range(1,37,1);
 $arr_blue = range(1,13,1);
 //随机数取出了下标,不是值
 $a = array_rand($arr_red,6);
 $b = array_rand($arr_blue,1);
 //美化一下
 unset($a[0]);
 unset($b[0]);
 echo '你要的自选***号红球为:';
 var_dump($a);
 echo '你要的自选***号蓝球为:';
 var_dump($b);

运行实例 »

点击 "运行实例" 按钮查看在线实例

 

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