3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $result = array( array("claim_id" => 1, "forename" => "foo", "surname" => "bar", "date" => "2013-12-01"), array("claim_id" => 2, "forename" => "foo2", "surname" => "bar2", "date" => "2013-12-02"), array("claim_id" => 3, "forename" => "foo3", "surname" => "bar3", "date" => "2013-12-03") ); $fp = fopen('php://output', 'w'); foreach($result AS $row) { if(!isset($header)) { $header = array_keys($row); fputcsv($fp, $header); } fputcsv($fp, $row); } fclose($fp);
Output for 5.1.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
claim_id,forename,surname,date 1,foo,bar,2013-12-01 2,foo2,bar2,2013-12-02 3,foo3,bar3,2013-12-03
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function fputcsv() in /in/ZumpB on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: fputcsv() in /in/ZumpB on line 13
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: fputcsv() in /in/ZumpB on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: fputcsv() in /in/ZumpB on line 13