<?php
$str = "apple pear banana orange";
$str_splode = explode(' ',$str);
print_r(showCombo(array(), $str_splode));
function showCombo($str_arr, $arr){
$ret = array();
foreach($arr as $val){
if(!in_array($val, $str_arr)){
$temp = $str_arr;
$temp[] = $val;
print_r($temp);
$comb = showCombo($temp, $arr);
if(count($comb) > 0)
$ret[] = $comb;
}
}
return $ret;
}
?>