手机
当前位置:查字典教程网 >编程开发 >php教程 >php生成数组的使用示例 php全组合算法
php生成数组的使用示例 php全组合算法
摘要:复制代码代码如下:

复制代码 代码如下:

<?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>";

【php生成数组的使用示例 php全组合算法】相关文章:

用定制的PHP应用程序来获取Web服务器的状态信息

PHP遍历数组的方法汇总

使用php的swoole实现高效安全的ftp服务器

php数组随机排序实现方法

使用php+xslt在windows平台上

PHP生成plist数据的方法

使用函数递归实现基于php和MySQL的动态树型菜单

php实现统计网站在线人数的方法

php统计数组元素个数的方法

smarty模板判断数组为空的方法

精品推荐
分类导航