0
的陣列我有2個表中, 「首部」 和 「馬赫」:創建循環
頭:
STATO |ID |CAMPIONATO
Italy |5 |Serie A
Spain |1 |Primera Division
France|2 |Coppe de France
馬赫:
STATO |home |away |scoreH|scoreA|
Italy |juve |Milan |0 |0 |
Italy |Lazio |Roma |0 |1 |
Spain |Deportivo|Bilbao |1 |0 |
Spain |A Madrid |Sevilla |1 |2 |
France|Lille |Perigord |0 |0 |
我使用下面的PHP代碼,以提取數據。我應該創建一個包含標題中的陣列和小組賽
$num=0;
$mach=-1;
foreach($first as $row2){ // cycling once
foreach($header as $row){ // cycles x times
.... //Here recover the header data
$stato;
$id;
$campionato
for($i=0;$i<$count;++$i){ // in $count know how many times I have to do the cycle for each header (stato)
$mach=$mach+1;
.... // Here recover the mach data
$home;
$away;
$scoreH;
$scoreA;
$info[$mach]= array('home'=>$home,'away'=>$away,'scoreH'=>$scoreH,'scoreA'=>$scoreA);
$groups[$num]=array($info[$mach]);
}//end for cycles
$headerArray[$num]=array('header'=>['stato'=>$stato,'id'=>$id,'campionato'=>$campionato],'mach'=>$groups[$um]);
$num++;
} //end header cycles
$blockArray[]=array('incontri'=>$headerArray);
} //end first cycle
print_r($blockArray);
的問題是,它返回所有日期匹配$組(意大利,西班牙,法國)沒有隻向組頭的。 如果您使用此行的PHP代碼:每個標題
$Groups[$num] = array($info[$mach]);
,而不是隻返回最後一場比賽(週期):
array_push ($groups,$info[$mach]);
代替。
我想創建數組
['incontri'=>
[
header=>
['stato'=>Italy,'id'=>5,'campionato'=>Serie A],
mach=>
['home'=>Juve,'away'=>Milan,'scoreH'=>0,'scoreA'=>0],
['home'=>Lazio,'away'=>Roma,'scoreH'=>0,'scoreA'=>0]
],
[....],
]
我在做什麼錯?