简体   繁体   中英

PHP: foreach warnings on simplexml

PHP and XML question:

Here is the var_dump i get from parsed xml.

object(SimpleXMLElement)#47 (6) {
    ["link"]=> array(4) {
        ...
    }
    ["entry"]=> array(11) {
        ...
    }
}

However, when I use:

foreach ($parsedReturn->link as $item)

or,

foreach ($parsedReturn->entry as $item)

I get warnings as such:

PHP Warning: Invalid argument supplied for foreach()

“链接”可以是属性,因此您必须使用$parsedReturn['link']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM