hope all of you are doing ok. I'm having a problem with this, because I'm looking for a way to get all the combinations of an array of numbers, but I want to do it without any function, I don't think that's possible, all the answers I already saw on internet have some function or method to do that.
I try this, give this array:
$numbers=[1,2,3,4];
I built 4 for loops to take the position of the array, and create a number, but, it supposes to be 24 different combinations give that array, with my for loops I get 256 combination
for($i = 0; $i <= 3; $i++){
for($j = 0; $j <= 3;$j++){
for($k = 0;$k <= 3;$k++){
for($l = 0; $l <= 3;$l++){
echo "$numbers[$i]$numbers[$j]$numbers[$k]$numbers[$l] <br>";
}
}
}
}
>echo "Combinations: $contador \n";
Could someone please help me! (I want to get the combination on a new array per value, to compare later with a random number)