title: array_reduce() can't work as associative-array "reducer" for PHP?
body: <p>I have an associative array <code>$assoc</code>, and  need to reduce to it to a string, in this context</p>
  
  <pre class="lang-php prettyprint-override"><code>$OUT = "&lt;row";
  foreach($assoc as $k=&gt;$v) $OUT.= " $k=\"$v\"";
  $OUT.= '/&gt;';
  </code></pre>
  
  <p><strong>How to do <a href="https://stackoverflow.com/q/29200367/287948">in an elegant way</a> the same thing, but using <code>array_reduce()</code></strong> </p>
  
  <hr>
  
  <p>Near the same algorithm (lower performance and lower legibility) with <code>array_walk()</code> function,</p>
  
  <pre><code> array_walk(  $row, function(&amp;$v,$k){$v=" $k=\"$v\"";}  );
   $OUT.= "\n\t&lt;row". join('',array_values($row)) ."/&gt;";
  </code></pre>
  
  <p><em>Ugly</em> solution with <code>array_map()</code> (and again <code>join()</code> as <em>reducer</em>):</p>
  
  <pre><code>  $row2 = array_map( 
      function($a,$b){return array(" $a=\"$b\"",1);},
      array_keys($row),
      array_values($row)
    ); // or  
    $OUT ="&lt;row ". join('',array_column($row2,0)) ."/&gt;";
  </code></pre>
  
  <p>PS: apparently PHP's <code>array_reduce()</code> not support associative arrays (<strong>why??</strong>).</p>