-2
IM剛開: 「提供的foreach無效參數()」「爲foreach()提供的無效參數」讀取XML?
在的用於嘗試讀取XML
PHP的特定商品時的每一行:
$urls="http://www.floatrates.com/daily/usd.xml";
$url= $urls;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$feed = new SimpleXMLElement($data,LIBXML_NOCDATA);
foreach ($feed->channel->item as $item) {
$title = $item->title;
if (preg_match('/ARS/',$title)) {
echo $title;
}
}
弗拉基米爾的代碼有效。 – RockwoodON
偉大的作品!,但爲什麼行:「$頻道= $飼料 - >頻道;」? – Targaryen