Solve the problem: ask for an array of n elements to take out m elements into a new array, altogether can be combined into an array and output
[PHP]
$arr = Array (' A ', ' B ', ' C ', ' d ');
$result = Array ();
$t = Getcombinationtostring ($arr, 4);
Print_r ($t);
function getcombinationtostring ($arr, $m) {
if ($m ==1) {
return $arr;
}
$result = Array ();
$TMPARR = $arr;
unset ($tmpArr [0]);
for ($i =0; $i
$s = $arr [$i];
$ret = getcombinationtostring (Array_values ($TMPARR), ($m-1), $result);
foreach ($ret as $row) {
$result [] = $s. $row;
}
}
return $result;
}
?>
http://www.bkjia.com/PHPjc/477961.html www.bkjia.com true http://www.bkjia.com/PHPjc/477961.html techarticle solve the problem: ask for an array of n elements to take out m elements into a new array, altogether can be combined into an array and output [PHP]? php $arr = Array (a,b,c,d); $result = Array ();