我需要输出从我正在使用的foreach循环输出的内容,而没有围绕它的无关数组标记。我有一些输出的例子是......
SimpleXMLElement Object
(
[@attributes] => Array
(
[type] => text
)
[0] => SMEs spend £6.89bn on unused technology
)
我用来输出上述代码的是
$xml = simplexml_load_file('http://news.telecomsworldplc.co.uk/atom.xml');
echo "<pre>";
foreach($xml->entry as $entry){
foreach($entry->title as $title){
print_r($title);
}
}
echo "</pre>";
产出需要只是“中小企业在未使用的技术上花费68.9亿英镑”......我会使用它吗?
谢谢!
答案 0 :(得分:1)
尝试下面的代码,它在这里工作
$xml = simplexml_load_file('http://news.telecomsworldplc.co.uk/atom.xml');
echo "<pre>";
foreach($xml->entry as $entry){
foreach($entry->title as $key=>$title){
print_r($key." => ".$title. "<br/>");
}
}
echo "</pre>";
exit;