我做print_r($ img);结果就是这个
SimpleXMLElement Object
(
[0] => http://www.thestar.com.my/~/media/Images/TSOL/Photos-Gallery/features/2014/07/02/JamyYangMingjie020714.ashx?crop=1&w=460&h=345&
)
SimpleXMLElement Object
(
[0] => http://www.thestar.com.my/~/media/Images/TSOL/Photos-Gallery/features/2014/07/02/dominiclau020714.ashx?crop=1&w=460&h=345&
)
SimpleXMLElement Object
(
[0] => http://www.thestar.com.my/~/media/Images/TSOL/Photos-Gallery/features/2014/07/02/str2_s8_0207_s8tricovel1.ashx?crop=1&w=460&h=345&
)
我想只获取链接列表。所以我做$ img [0]它不起作用,为什么?
答案 0 :(得分:2)
您使用简单的foreach
循环:
foreach($img as $i) {
echo "<img src='". $i. "' />";
}