title: PHP no object error when array is null
body: <p>I have a RSS feed URL and I am using following PHP function to extract values from it.</p>
  
  <pre><code>$xml = simplexml_load_file($url);
  </code></pre>
  
  <p>Its working perfect when the <code>$url</code> generates some results. And I am using <code>count()</code> function to count the length of array thats extracted from RSS feeds.</p>
  
  <pre><code>$length=sizeof($xml-&gt;rs[0]-&gt;r);
  </code></pre>
  
  <p>But when there is no result in RSS it gives me error</p>
  
  <pre><code>Trying to get property of non-object in /home/****/public_html/index.php on line 5 
  </code></pre>
  
  <p>So is there a way to echo a message if there are no results in RSS feed URL.</p>
  
  <p>And when i do <code>print_r($xml)</code> ob no results <code>$xml</code> , i get </p>
  
  <p><code>SimpleXMLElement Object ( [@attributes] =&gt; Array ( [type] =&gt; noresults [code] =&gt; 1.1 ) [title] =&gt; SimpleXMLElement Object ( ) [subtitle] =&gt; SimpleXMLElement Object ( ) [text] =&gt; SimpleXMLElement Object ( ) [base] =&gt; SimpleXMLElement Object ( ) ) )</code></p>
  
  <p>I searched everywhere and found no solution.. Thanks for your help.</p>