title: XML node and values reversed using SimpleXMLElement and array_walk()
body: <p>I am trying to build an XML element from an array in PHP using an example that was posted elsewhere on this site. The XML string is being created as expected however the nodes and their values are reversed. For Example:</p>
  
  <pre><code>$params = array(
          "email" =&gt; 'me@gmail.com'
          ,"pass" =&gt; '123456'
          ,"pass-conf" =&gt; '123456'
      );
      $xml = new SimpleXMLElement('&lt;root/&gt;');
      array_walk_recursive($params, array($xml, 'addChild'));
      echo $xml-&gt;asXML();
  </code></pre>
  
  <p>Now what I am expecting to be returned is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
    &lt;root&gt;
      &lt;email&gt;me@gmail.com&lt;/email&gt;
      &lt;pass&gt;123456&lt;/pass&gt;
      &lt;pass-conf&gt;123456&lt;/pass-conf&gt;
    &lt;/root&gt;
  </code></pre>
  
  <p>However, what I keep getting is the node names as values and values as node names:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
    &lt;root&gt;
      &lt;me@gmail.com&gt;email&lt;/me@gmail.com&gt;
      &lt;123456&gt;pass&lt;/123456&gt;
      &lt;123456&gt;pass-conf&lt;/123456&gt;
    &lt;/root&gt;
  </code></pre>
  
  <p>I have tested switching the key with the value in the <code>$params</code> array, but that seems like a lazy hack to me. I believe the issue lies within my callback in <code>array_walk_recursive</code>, but I'm not sure how exactly to make it work. I am open to recommendations on better ways to convert a PHP array to XML. I just tried this because it seemed simple and not convoluted. (haha..)</p>