我正在尝试在 PHP 中使用 JSON,我想知道当从 json_decode 返回信息时,是否有人可以帮助我访问 $events=>$url。什么是可变路径。返回数据中有许多循环记录,我正在使用类似的东西:
$data = json_decode($feeds,true);
foreach($data as $item=>$events) {
$date = $events=>$month.'/'.$events=>$day.'/'.$events=>$year;
$events.='<li><span class="engindate">'.$date.'</span><br /><span class="source">'.$item["title"].'</span><br /><a href="'.$item["url"].'">'.$item["details"].'</a></li>';
}
这是 JSON 示例(是的,我知道它不完整)
{
"month": 5,
"year": 2013,
"events": [
{
"url": "http://www.engin.umich.edu/college/about/cal/events/2013/may/shavuot-ends",
"id": "shavuot-ends",
"month": 5,
"year": 2013,
"day": 16,
"startTime": "1:42",
"endTime": "1:42",
"hideTime": "true",
"deadline": "true",
"am_pm": "pm",
"am_pm_start": "pm",
"am_pm_end": "pm",
"title": "Shavuot ends",
"location": "",
"details": "Shavuot runs from May 14 to May 16.",
"host": "Michigan Engineering",
"event_type": "Holiday",
"image": {
"src": "http://www.engin.umich.edu/++resource++umich_images/default_event.jpg",
"alt": "Shavuot ends"
}
},...