0
我正在使用SimpleXML進行非常基本的xml結構,並且在查找到特定值後,我無法從結果中找出結果。以下是我的代碼從php中獲取數組的價值問題
$xml = new SimpleXMLElement($xmlStr);
foreach($values['type'] as $type)
{
$res = $xml->xpath("/domains/type[name='$type']/price");
$price = (isset($res[0][0]))? $res[0][0] : 'US 0.0' ;
$domain = $dname.$type;
if(!checkdnsrr($domain)){
$avails[$domain]['available'] = 'yes';
$avails[$domain]['price'] = $price;
}
else
$avails[$domain] = 'no';
}
echo '<pre>';
print_r($avails);
echo '</pre>';
下面是輸出。
Array (
[eee.com] => no
[eee.net] => Array
(Blockquote
[available] => yes
[price] => SimpleXMLElement Object
(
[0] => US $20
)
)
我該如何擺脫這個SimpleXMLElement對象,只有它的價值。