title: Getting an array from object using SimpleXMLElement
body: <p>I'm having some problems getting the array in these objects.  When I print_r(), the following code is printed.  $message_object is the name of the object.</p>
  
  <pre><code>SimpleXMLElement Object
  (
      [header] =&gt; SimpleXMLElement Object
          (
              [responsetime] =&gt; 2012-12-22T14:10:09+00:00
          )
  
      [data] =&gt; SimpleXMLElement Object
          (
              [id] =&gt; Array
                  (
                      [0] =&gt; 65233
                      [1] =&gt; 65234
                  )
  
              [account] =&gt; Array
                  (
                      [0] =&gt; 20992
                      [1] =&gt; 20992
                  )
  
              [shortcode] =&gt; Array
                  (
                      [0] =&gt; 3255
                      [1] =&gt; 3255
                  )
  
              [received] =&gt; Array
                  (
                      [0] =&gt; 2012-12-22T11:04:30+00:00
                      [1] =&gt; 2012-12-22T11:31:08+00:00
                  )
  
              [from] =&gt; Array
                  (
                      [0] =&gt; 6121843347
                      [1] =&gt; 6121820166
                  )
  
              [cnt] =&gt; Array
                  (
                      [0] =&gt; 24
                      [1] =&gt; 25
                  )
  
              [message] =&gt; Array
                  (
                      [0] =&gt; Go tramping wellington 11-30
                      [1] =&gt; Go drinking Matakana 2pm
                  )
  
          )
  
  )
  </code></pre>
  
  <p>I'm trying to get the id arrays out of the objects with a foreach:</p>
  
  <pre><code>foreach($message_object-&gt;data-&gt;id AS $id) {
      print_r($id);
  }
  </code></pre>
  
  <p>The following reply is sent:</p>
  
  <pre><code>SimpleXMLElement Object ( [0] =&gt; 65233 ) SimpleXMLElement Object ( [0] =&gt; 65234 )
  </code></pre>
  
  <p>How do I get the value of [0] or am I going about this wrong? and is there a way to loop though the results and get the object keys?</p>
  
  <p>I have tried to echo $id[0] but it returns no result.</p>