title: Add xml child to array php
body: <p>I'm trying to add each <code>&lt;outfit&gt;Subnodes&lt;/outfit&gt;</code> subnodes to an array using php.</p>
  
  <p><strong>My actual code:</strong></p>
  
  <pre><code>public static function get_outfits($username) {
     $files = self::user_files($username);
     $data  = self::request($files['outfits']);
     $data  = @simplexml_load_string($data);
     if ( $data &amp;&amp; count(@$data-&gt;xpath('//outfits/outfit')) &gt; 0 ) {
        foreach(@$data-&gt;xpath('//outfits/outfit/*') as $items) {
           $response['outfits']['items'][] = array(
              "url"          =&gt; (string)$items['url'],
              "c"            =&gt; (string)$items['c'],
              "c2"           =&gt; (string)$items['c2'],
              "displayName"  =&gt; (string)$items['displayName'],
              "z"            =&gt; (string)$items['z'],
              "id"           =&gt; (string)$items['id'],
              "isUgc"        =&gt; (string)$items['isUgc']
           );
        }
     }
     return (isset($response) ? $response : false);
  }
  </code></pre>
  
  <p><strong>The xml document looks like the following:</strong> <a href="http://outfits.zwinky.com/users/220/287/_perverted/outfits.xml" rel="nofollow">http://outfits.zwinky.com/users/220/287/_perverted/outfits.xml</a></p>
  
  <p>Sadly the code is saving every existing child into one array. But I'm trying to create an array index for each <code>&lt;outfit&gt;&lt;/outfit&gt;</code> node which should contain the child elements.</p>
  
  <p><strong>For example:</strong></p>
  
  <p>Array[0] = Everything between the first <code>&lt;outfit&gt;&lt;outfit&gt;</code></p>
  
  <p>Array[1] = Everything between the second <code>&lt;outfit&gt;&lt;outfit&gt;</code></p>
  
  <p>Does anyone have an idea, how to create this?</p>