Pls Clarify the issue


My Function :


function makeCombination ($my_arr, $k){
reset($my_arr);
$enne=count($my_arr);
//echo "$enne";

$num_comb=$this->numComb($enne,$k);

//echo "$num_comb";
$combinations=array();
$pos=array();

for( $i = $k; $i > 0; $i--) { 
$pos[$i] = $i;   

}

$counter=0;

while(true) {  


$temp=array();
$i=$k;

$counter +=1;


if ($counter>1){
while($i-- > 0) {

$temp[$i] = $my_arr[$pos[$i]]; 

}
}
else{

for ($i=$k;$i>0;$i--){
    //$i1=$i-1;
$temp[$i-1] = $my_arr[$pos[$i]-1]; 
}
print_r($temp);
}


$combinations[]=$temp;
reset($combinations);

$i=1;


 while(($i < $k) && (($pos[$i-1] + 1) == $pos[$i])) ++$i;  

   if(++$pos[--$i] >= $enne)  
   break;  
    while(--$i >= 0){
  $pos[$i] = $i;    

}



}

reset($combinations);
return $combinations;


}



my php :

  include "Combinatorics.php";
                        $mycalc=new Combinatorics;
                       for($j=0; $j<sizeof($productdetails); $j++)
                        {
                        $combwr=$mycalc->makeCombination(array($productdetails[$j]['nam']),$notitle);
                        echo"and they are the followings:</BR>";
                        foreach($combwr as $key=>$value){
                        echo $key .": ";
                        foreach ($value as $key2=>$value2){
                        echo $value2;
                        }
                        echo "</BR>";
                        }
                        }

You need to post this in the forum "PHP"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.