3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function fputcsvdata($dataArray,$delimiter,$enclosure) { // Write a line to a file // $filePointer = the file resource to write to // $dataArray = the data to write out // $delimeter = the field separator // Build the string $string = ""; // No leading delimiter $writeDelimiter = FALSE; foreach($dataArray as $dataElement) { // Replaces a double quote with two double quotes $dataElement=str_replace("\"", "\"\"", $dataElement); // Adds a delimiter before each field (except the first) if($writeDelimiter) $string .= $delimiter; // Encloses each field with $enclosure and adds it to the string $string .= $enclosure . $dataElement . $enclosure; // Delimiters are used every time except the first. $writeDelimiter = TRUE; } // end foreach($dataArray as $dataElement) // Append new line $string .= "\n"; return $string; } $data = array('this','is some', 'csv "stuff", you know.', '"', ';'); var_dump(fputcsvdata($data)); //$out = fopen('php://output', 'w'); //fputcsv($out, $data); //fclose($out);
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function fputcsvdata(), 1 passed in /in/HeArB on line 38 and exactly 3 expected in /in/HeArB:2 Stack trace: #0 /in/HeArB(38): fputcsvdata(Array) #1 {main} thrown in /in/HeArB on line 2
Process exited with code 255.
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 2 for fputcsvdata(), called in /in/HeArB on line 38 and defined in /in/HeArB on line 2 Warning: Missing argument 3 for fputcsvdata(), called in /in/HeArB on line 38 and defined in /in/HeArB on line 2 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 string(39) "thisis somecsv ""stuff"", you know.""; "
Output for hhvm-3.10.0 - 3.12.0
Warning: fputcsvdata() expects exactly 3 parameters, 1 given in /in/HeArB on line 10 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: delimiter in /in/HeArB on line 20 Notice: Undefined variable: enclosure in /in/HeArB on line 23 Notice: Undefined variable: enclosure in /in/HeArB on line 23 string(39) "thisis somecsv ""stuff"", you know.""; "
Output for 5.2.3 - 5.4.45
Warning: Missing argument 2 for fputcsvdata(), called in /in/HeArB on line 38 and defined in /in/HeArB on line 2 Warning: Missing argument 3 for fputcsvdata(), called in /in/HeArB on line 38 and defined in /in/HeArB on line 2 string(39) "thisis somecsv ""stuff"", you know.""; "
Output for 5.1.1 - 5.2.2
<br /> <b>Warning</b>: Missing argument 2 for fputcsvdata(), called in /in/HeArB on line 38 and defined in <b>/in/HeArB</b> on line <b>2</b><br /> <br /> <b>Warning</b>: Missing argument 3 for fputcsvdata(), called in /in/HeArB on line 38 and defined in <b>/in/HeArB</b> on line <b>2</b><br /> string(39) "thisis somecsv ""stuff"", you know.""; "
Output for 5.1.0
<br /> <b>Fatal error</b>: fatal flex scanner internal error--end of buffer missed in <b>/in/HeArB</b> on line <b>41</b><br />
Process exited with code 255.
Output for 4.3.0 - 5.0.5
<br /> <b>Warning</b>: Missing argument 2 for fputcsvdata() in <b>/in/HeArB</b> on line <b>2</b><br /> <br /> <b>Warning</b>: Missing argument 3 for fputcsvdata() in <b>/in/HeArB</b> on line <b>2</b><br /> string(39) "thisis somecsv ""stuff"", you know.""; "