title: Access SimpleXMLElement child elements as an array
body: <p>How can I Access the SimpleXMLElement childs as an array?</p>
  
  <pre><code>SimpleXMLElement(9) {
   name =&gt; "John" (11)
   phone =&gt; array(2) [
      0 =&gt; "556 221 000" (19)
      1 =&gt; "312 555 110" (19)
   ]
  }
  </code></pre>
  
  <p>According to this article <a href="http://www.sitepoint.com/parsing-xml-with-simplexml/" rel="nofollow">http://www.sitepoint.com/parsing-xml-with-simplexml/</a> I should easily access it via </p>
  
  <pre><code>$sxElement-&gt;phone[0];
  </code></pre>
  
  <p>But then dump returns just:</p>
  
  <pre><code>SimpleXMLElement(0)
  </code></pre>
  
  <p>I need to access this in a for cycle. Thanks.</p>
  
  <p>Edit (XML example): </p>
  
  <pre><code>&lt;company&gt;
    &lt;phonebook&gt;
      &lt;name&gt;John&lt;/name&gt;
      &lt;phone&gt;556 221 000&lt;/phone&gt;
      &lt;phone&gt;312 555 110&lt;/phone&gt;
    &lt;/phonebook&gt;
  &lt;/company&gt;
  </code></pre>
  
  <p>I need to go thru my foreach on another object and attach the correct phone according to iterator value.</p>