码迷,mamicode.com
首页 > Web开发 > 详细

php知识案列

时间:2016-12-01 03:37:44      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:++   result   php   nbsp   number   顺序   随机数生成   echo   知识   

                    

 n个不重复的随机数生成代码

<?php //range 是将1到100 列成一个数组 $numbers = range (1,100);

//shuffle 将数组顺序随即打乱 shuffle ($numbers);

//array_slice 取该数组中的某一段 $no=6; $result = array_slice($numbers,0,$no);

for ($i=0;$i<$no;$i++){ echo $result[$i]."<br>"; } print_r($result); ?>

//range 是将1到100 列成一个数组 $numbers = range (1,100);

//shuffle 将数组顺序随即打乱 shuffle ($numbers);

//array_slice 取该数组中的某一段 $no=6; $result = array_slice($numbers,0,$no);

for ($i=0;$i<$no;$i++){ echo $result[$i]."<br>"; } print_r($result); ?>

php知识案列

标签:++   result   php   nbsp   number   顺序   随机数生成   echo   知识   

原文地址:http://www.cnblogs.com/xa4312cs/p/6120332.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!