title: Codeigniter Unidentified Index
body: <p>I have a function <code>foo</code> that returns an array with the below structure and what I am trying to work out is there a better way to structure my PHP as I am unsure about the indexing within the foreach as I want every <code>ListingId</code>  </p>
  
  <p><strong>Goal:</strong></p>
  
  <p>I am wanting to write a <code>foreach</code> loop that gets the XML <code>&lt;Name&gt;</code> from an external XML document (Have not coded this section yet as I need to pass the <code>ListingID</code> from <code>foo</code>into the url to get the <code>&lt;Name&gt;</code>) </p>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>    $test0 = $this-&gt;foo();
      $test = $test0[0]['ListingId'];
  </code></pre>
  
  <p><strong>Structure:</strong></p>
  
  <pre><code>Array ( [0] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 532712629 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3400- ) ) [1] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 532712202 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3400- ) ) [2] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 532711566 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3400- ) ) [3] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 532710864 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3400- ) ) [4] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 532710271 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3400- ) ) [5] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 532691526 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3400- ) ) [6] =&gt; Array ( [ListingId] =&gt; SimpleXMLElement Object ( [0] =&gt; 527496168 ) [ListingCategory] =&gt; SimpleXMLElement Object ( [0] =&gt; 0350-5748-3399- ) ) ) 
  </code></pre>