title: Convert associative array of indexed arrays into multi-line csv text
body: <p>I have a multidimensional array in which the first level keys needs to be the first line of data in .csv string.</p>
  <p>The rows of indexed elements need to be transpose and converted into subsequent lines of csv text.</p>
  <p>The output will be identical to a .csv file's contents, but I don't want a file to be created, just as a .csv string.</p>
  <p>Sample data:</p>
  <pre><code>$data = [
       'dates' =&gt; ['2010-01-02', '2011-02-03', '2011-02-04'],
       'type1' =&gt; ['data1', 'data2', 'data3'],
       'type2' =&gt; ['data4', 'data5', 'data6']
  ];
  </code></pre>
  <p>Desired output string:</p>
  <pre><code>dates,type1,type2
  2010-01-02,data1,data4
  2011-02-03,data2,data5
  2011-02-04,data3,data6
  </code></pre>