0

I have a foreach to loop through the data provided by a PDO SQL query:

foreach ($team as $row){
    $count++;
    $teamNumber = 'team'.$count;
    if ($currentScores[0]['team'.$count] == ""){
        $red = "red";
    }
    echo "<strong><font color='".$red."'>".$row['name']."</font></strong>";
    echo $currentScores[0]['team'.$count];
    if ($count < 2) 
        echo " vs ";
}

Now, I want to loop again through the $team array but it just returns the last value of the array during the second loop.

I tried the same thing:

foreach ($team as $row) {
.....
.......
}

How could I run again through the array?

Gwenc37
  • 2,064
  • 7
  • 18
  • 22
user2509541
  • 268
  • 4
  • 14

1 Answers1

1

Simple enough, just do a foreach loop on $row as you have previously.

foreach($array as $key => $val) {
    foreach($val as $a => $b) {
        echo $b;
    }
}
Bill
  • 11
  • 1