Hello, first of all thanks for letting me register in this forum, I've been reading some of the topics and they really helped me so far!
I am trying to make a loop for my school project but unfortunately I couldn't solve it alone...
These are my variables:
<?php
$_POST["1st_phase_aL"] = "Paradise";
$_POST["1st_phase_aL_act_a"] = "Sonya and me";
$_POST["1st_phase_aL_act_b"] = "Katie and me";
$phases = array("1st_phase_");
$letters = range('A', 'Z');
$firsts = array();
for($i = 'a';$i <= 'z';$i++){
for($j = 'a'; $j <= 'z';$j++){
foreach ($phases as $phase) {
foreach ($letters as $letter) {
$firsts[] = $phase . $i . $letter;
$firsts[] = $phase . $i . $letter . "_act_" . $j;
}
}
}
}
foreach($firsts as $first) {
if(isset($_POST[$first]) && $_POST[$first]!="")
echo "*" . $_POST[$first] . "<br/>";
}
?>
This results in a double "paradise" plus Katie and Sonya. Why does paradise appears 2 times?
I have 3 cycles like this for all the championship stages (1st stage, 2nd stage, 3rd stage, semi-final and great-final), every single one of them have letters from A to Z in the structure that I presented in this example... Can somebody help me with a great loop to solve this problem?
And tell me one thing, even with a loop with all the phases, if I get them all in the array first[], how would I display them on the HTML?
I want to separate them by phase, that's why I am doing a loop for each phase...
Short version:
- Loop is giving me duplicate result (major problem)
- Would like to have a loop for all the competition stages
- If I have an array with all the competition stages, how would I echo them into the html (I cannot refer to the phase name, right? I want to group them into phases)
THANKS!