亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php生成數(shù)組的使用示例 php全組合算法

 更新時(shí)間:2014年01月16日 10:11:05   作者:  
要求實(shí)現(xiàn)一個(gè)7個(gè)元素的數(shù)組,取出這個(gè)數(shù)組中的5個(gè)元素,生成新的數(shù)組,這些數(shù)組是唯一的

復(fù)制代碼 代碼如下:

<?php
$arr = array(1,2,3,4,5);
/*
@ res  組裝好的每一注的每個(gè)元素
@ $a 臨時(shí)數(shù)組
@ $index 數(shù)組索引
@ $arr 請求的數(shù)組
@ $b 最后要的結(jié)果
*/
$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>";  

相關(guān)文章

最新評論