我得到了一个像这样的数组:
array(28) {
[0]=> array(8) { ["jornada"]=> string(1) "1" ["team1"]=> string(12) "LEGANES F.C." ["team2"]=> string(9) "LAS CONOS" }
[1]=> array(8) { ["jornada"]=> string(1) "1" ["team1"]=> string(13) "BABACHAS F.C." ["team2"]=> string(19) "QUIRQUINCHAS VERDES" }
[2]=> array(8) { ["jornada"]=> string(1) "2" ["team1"]=> string(7) "TSU CHU" ["team2"]=> string(12) "SANTINO F.C." }
[3]=> array(8) { ["jornada"]=> string(1) "2" ["team1"]=> string(11) "LIBERO F.C." ["team2"]=> string(9) "LAS PUMAS" }
[4]=> array(8) { ["jornada"]=> string(1) "3" ["team1"]=> string(6) "PUCARA" ["team2"]=> string(15) "EL REJUNTE F.C." }
我的问题是,我怎样才能得到不同的"jornada"的值?因为我必须通过"jornada"创建一个fixture分组,例如:
jornada 1 :
LEGANES vs LAS CONOS
BABACHAS vs QUIRQUINCHAS
jornada 2:
TSU CHU vs SANTINO
LIBERO vs LAS PUMAS
谢谢你的帮助,对不起我的英语。
您可以将它们重新排列成一个新的数组,该数组具有以下分组…
$grouped = array();
foreach ($data as $row) {
$grouped[$row['jornada']][] = $row;
}
现在你可以这样做:
foreach ($grouped as $jorndada => $matches) {
echo "Jornada $jornadan";
foreach ($matches as $match) {
echo $match["team1"] ." vs ". $match["team2"] . PHP_EOL;
}
}