源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php生成数组的使用示例 php全组合算法

  • 时间:2021-10-30 02:27 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php生成数组的使用示例 php全组合算法
[u]复制代码[/u] 代码如下:
<?php $arr = array(1,2,3,4,5); /* @ res  组装好的每一注的每个元素 @ $a 临时数组 @ $index 数组索引 @ $arr 请求的数组 @ $b 最后要的结果 */ $a = array(); $b = array(); $total = 0; format($a,0,$arr); function format($res,$index,$arr){  global $total;  global $b;  $new_arr = $res;  $n_arr = array();  if($index == count($arr)){   if(count($new_arr)==5){    $b[]  = $new_arr;    echo "<pre>";    $total++;    }     return;  }  format($new_arr,$index+1,$arr);  $new_arr[] = $arr[$index];  format($new_arr,$index+1,$arr); } echo "<pre>"; print_r($b); echo "</pre>";  
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部