3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ ['foo', 'bar', 'baz="bazinga!"'], ['foo', 'bar', 'baz="bazinga!"'], ['foo', 'bar', 'baz="bazinga!"'], ['foo', 'bar', 'baz="bazinga!"'], ['foo', 'bar', 'baz="bazinga!"'], ['foo', 'bar', 'baz="bazinga!"'] ]; ob_start(); $buffer = fopen('php://output', 'w'); array_walk($a, function ($row) use ($buffer) { fputcsv($buffer, $row); }); $csv = ob_get_clean(); echo $csv;
based on SluK7
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.2.6
foo,bar,"baz=""bazinga!""" foo,bar,"baz=""bazinga!""" foo,bar,"baz=""bazinga!""" foo,bar,"baz=""bazinga!""" foo,bar,"baz=""bazinga!""" foo,bar,"baz=""bazinga!"""