0
林有關於對象的數組一些問題,出於某種原因,我不能訪問每個對象的ID的foreach,它給我的錯誤:錯誤上對象的數組
ErrorException in SController.php line 51:
Undefined index: id
在我controlller方法:從 「$ todayMatches-> getAllMatchesFromDate()」
public function today()
{
$todayMatches = new SportRadarService();
$temp = [];
foreach ($todayMatches->getAllMatchesFromDate() as $match){
array_push($temp,$match["id"]);
}
return $temp;
}
的樣本數據:
[
{
"id": "sr:11964344",
"scheduled": "2017-08-09T15:00:00+00:00",
},
{
"id": "sr:767667",
"scheduled": "2017-08-012T15:00:00+00:00",
},
....
]
我想匹配不是一個數組,它是一個對象。 –