+ 1
Make a function that will accept any array of 3 positions and print all possible combinations of its elements.
can someone help me with the following Make a function that will accept any array of 3 positions and print all possible combinations of its elements. Example: Suppose we have: $ array = [red, blue, green] Based on the above array, the output will be: red blue green red blue red green blue green red blue green
3 Réponses
+ 1
Show your attempt first, please. We will fix it.
+ 1
I wrote this to show me the original table
$colors=['red','blue','green'];
for($i=0;$i<count($colors);$i++){
echo '<ul><li>'.$colors[$i].'</li></ul>';
}
for($i=2;$i<count($colors);$i++){
echo '<ul><li>'.$colors[0].' '.$colors[1].'</li></ul>';
echo '<ul><li>'.$colors[0].' '.$colors[2].'</li></ul>';
echo '<ul><li>'.$colors[1].' '.$colors[2].'</li></ul>';
}
i have stuck. when i try to enter in function i take errors and
and I do not know if the second code I wrote is spelled correctly
+ 1
I fix it!!!