PHP object holding XML data

后端 未结 2 1885
旧时难觅i
旧时难觅i 2021-01-29 08:46

How to check whether any data is returned in Object $twitter_xml for query abc or its empty?

Following is the code:

 $url=         


        
相关标签:
2条回答
  • 2021-01-29 08:50

    This will give you a count of items:

    count($twitter_xml->channel->item);
    
    0 讨论(0)
  • 2021-01-29 09:01

    I'm not sure what Twitter returns, but you should be able to do an isset() on a value you expect to exist.

    See http://php.net/manual/en/function.isset.php

    E.g.

    if(isset($twitter_xml->name))
    {
        // XML has a 'name' element
    }
    else
    {
        // No 'name' element
    }
    
    0 讨论(0)
提交回复
热议问题