1
所以,我試圖解析XML和得到一些價值出來的:simplexml_load_string不分析正確
$xml = simplexml_load_string(file_get_contents('http://www.bnr.ro/nbrfxrates.xml'));
$currency = [];
foreach($xml->Body->Cube->Rate as $rate)
{
$currency[] = [
"name" => $rate["currency"],
"value" => $rate,
"multiplier" => $rate["multiplier"]
];
}
return $currency;
我的$率變量應該是價格標籤內的值(例如:1.0806 ),而不是它給了我這樣的:
object(SimpleXMLElement)[110]
public '@attributes' =>
array (size=1)
'currency' => string 'AED' (length=3)
你' 「值」=>(串)$率之後是潛在的,' ? –
@JonStirling嗯它的工作原理。 –