title: PHP - Echo key value of the array items
body: <p>I need to echo the key value of an array.</p>
  
  <p>This is how im outputting my array:</p>
  
  <pre><code>foreach($xml-&gt;channel-&gt;item as $item) {
    $item-&gt;title
  }
  </code></pre>
  
  <p>I've tried adding:</p>
  
  <pre><code>foreach($xml-&gt;channel-&gt;item as $key =&gt; $item)
  </code></pre>
  
  <p>But the value I echo just comes out as: <code>item</code></p>
  
  <p>Any ideas?</p>
  
  <p>Var Dump of item results:</p>
  
  <pre><code>var_dump($xml-&gt;channel-&gt;item);
  
      object(SimpleXMLElement)#4 (5) { 
  ["title"]=&gt;  string(33) "BA and union agree to end dispute" 
  ["description"]=&gt;  string(118) "British Airways and the Unite union reach an agreement which could end the long-running dispute between the two sides." 
  ["link"]=&gt;  string(61) "http://www.bbc.co.uk/go/rss/int/news/-/news/business-13373638" 
  ["guid"]=&gt;  string(43) "http://www.bbc.co.uk/news/business-13373638" 
  ["pubDate"]=&gt;  string(29) "Thu, 12 May 2011 12:33:38 GMT" 
  } 
  </code></pre>