似乎没有读取外部URL,因此未检索到该值。我可以知道为什么我的代码不起作用吗?
function GetFeed($url){
$feed = simplexml_load_file($url);
$feed_array = array();
foreach($feed->channel->item as $story){
$story_array = array (
'title' => $story->title,
'description' => $story->description
);
array_push($feed_array, $story_array);
}
return $feed_array;
}
$url = 'http://www.channelnewsasia.com/rss/latest_cna_sg_rss.xml';
$news = GetFeed($url);
echo $news[0]['title'];