title: PHP not creating array correctly from XML?
body: <p>I am really confused with why this is happening have spent (quite a lot of time, more than I would like to admit). Basically when it gets to Date it does not add the date to the array whereas Time is absolutely fine. </p>
  
  <p><strong>XML Code Example</strong></p>
  
  <pre><code>&lt;xml&gt;
  &lt;Route id="1"&gt;
      &lt;itdDateTime&gt;
          &lt;itdDate day="28" month="10" year="2012" weekday="-1"/&gt;
          &lt;itdTime hour="12" minute="53"/&gt;
      &lt;/itdDateTime&gt;
  &lt;/Route&gt;
  &lt;Route id="2"&gt;
      &lt;itdDateTime&gt;
          &lt;itdDate day="3" month="12" year="2012" weekday="-1"/&gt;
          &lt;itdTime hour="8" minute="14"/&gt;
      &lt;/itdDateTime&gt;
  &lt;/Route&gt;
  &lt;Route id="3"&gt;
      &lt;itdDateTime&gt;
          &lt;itdDate day="3" month="12" year="2012" weekday="-1"/&gt;
          &lt;itdTime hour="9" minute="16"/&gt;
      &lt;/itdDateTime&gt;
  &lt;/Route&gt;
  </code></pre>
  
  <p><strong>PHP Code Example</strong></p>
  
  <pre><code>foreach($route-&gt;childNodes as $node) {
      if ($node-&gt;nodeName == 'itdDateTime') {
          foreach ($node-&gt;childNodes as $child) {
              $dateAttr = $child-&gt;attributes;
              $x[$i]['leave'] = array();
              $x[$i]['leave']['date'] = array();
              $x[$i]['leave']['time'] = array();
              foreach ($dateAttr as $index=&gt;$attr) {
                  $x[$i][$attr-&gt;nodeName] = $attr-&gt;nodeValue;             
                  if ($index == 'minute' || $index == 'hour') {
                      $x[$i]['leave']['time'][$attr-&gt;nodeName] = $attr-&gt;nodeValue;
                  } else {
                      $x[$i]['leave']['date'][$attr-&gt;nodeName] = $attr-&gt;nodeValue;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>Array example</strong></p>
  
  <pre><code>    Array
  (
      [0] =&gt; Array
          (
              [active] =&gt; 1
              [delete] =&gt; 0
              [changes] =&gt; 2
              [distance] =&gt; 966
              [alternative] =&gt; 0
              [publicDuration] =&gt; 01:19
              [individualDuration] =&gt; 00:22
              [print] =&gt; 0
              [routeIndex] =&gt; 1
              [hasFrequency] =&gt; 1
              [routeTripIndex] =&gt; 1
              [cTime] =&gt; 20121028113640847
              [searchMode] =&gt; 1
              [vehicleTime] =&gt; 53
              [method] =&gt; itp
              [selected] =&gt; 1
              [leave] =&gt; Array
                  (
                      [date] =&gt; Array
                          (
                          )
  
                      [time] =&gt; Array
                          (
                              [hour] =&gt; 12
                              [minute] =&gt; 53
                          )
  
                  )
  
              [day] =&gt; 28
              [month] =&gt; 10
              [year] =&gt; 2012
              [weekday] =&gt; 1
              [hour] =&gt; 12
              [minute] =&gt; 53
          )
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>So basically the issue is that the date (day, month, weekday) should be entered into 
  [leave][date] .. (example) [leave][date][day]</p>
  
  <p>Even having no IF Statement, and entering it into [leave] array only doesnt work for example</p>
  
  <pre><code>$x[$i]['leave'][$attr-&gt;nodeName] = $attr-&gt;nodeValue;
  </code></pre>
  
  <p>So Im basically unsure and dont understand why it will show in the first array (such as next to Leave as per the example)</p>
  
  <pre><code>$x[$i][$attr-&gt;nodeName] = $attr-&gt;nodeValue;
  </code></pre>
  
  <p>Any advice or help on this would be greatly appreciated.</p>