我有一个foreach来遍历PDO SQL查询提供的数据:
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 ";
}
现在,我想再次遍历$ team数组,但它只是在第二个循环中返回数组的最后一个值。
我尝试过同样的事情:
foreach ($team as $row) {
.....
.......
}
我怎么能再次通过阵列?
答案 0 :(得分:1)
很简单,就像你之前在$ row上做一个foreach循环一样。
foreach($array as $key => $val) {
foreach($val as $a => $b) {
echo $b;
}
}