EDIT
The following code gives the result that you want (not just for array with 3 element like the code before the edited asnwer) but i doubt it is the best possible way, but since no one provided an answer you can use this until you find a better way
$myArray = array('A','B','C','D');
$result=array_combinations($myArray);
print_r($result);
function array_combinations($array){
$result=[];
for ($i=0;$i<count($array)-1;$i++) {
$result=array_merge($result,combinations(array_slice($array,$i)));
}
return $result;
}
function combinations($array){
//get all the possible combinations no dublicates
$combinations=[];
$combinations[]=$array;
for($i=1;$i<count($array);$i++){
$tmp=$array;
unset($tmp[$i]);
$tmp=array_values($tmp);//fix the indexes after unset
if(count($tmp)<2){
break;
}
$combinations[]=$tmp;
}
return $combinations;
}
results
Array
(
[0] => Array
(
[0] => A
[1] => B
[2] => C
[3] => D
)
[1] => Array
(
[0] => A
[1] => C
[2] => D
)
[2] => Array
(
[0] => A
[1] => B
[2] => D
)
[3] => Array
(
[0] => A
[1] => B
[2] => C
)
[4] => Array
(
[0] => B
[1] => C
[2] => D
)
[5] => Array
(
[0] => B
[1] => D
)
[6] => Array
(
[0] => B
[1] => C
)
[7] => Array
(
[0] => C
[1] => D
)
)
you can find a demo here