3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_csv_data($data,$use_key=false,$delm=',') { $output = NULL; if(is_array($data)) { if($use_key == false) { if(isset($data[0]) && is_array($data[0])) { foreach($data as $key) { $output .= implode($delm,$key); $output .= "\n"; } } else { $output .= implode("$delm", $data)."\n"; } } else { foreach($data as $key => $value) { $output .= "$key{$delm}$value\n"; } } } else { $output = $data; } if(empty($output)) { trigger_error('OUTPUT WAS EMPTY!', E_USER_ERROR); return false; } return $output; } $data = array('"this"','is some', 'csv "stuff", you know.'); var_dump(generate_csv_data($data)); $out = fopen('php://output', 'w'); fputcsv($out, $data); fclose($out);
Output for git.master, git.master_jit, rfc.property-hooks
string(38) ""this",is some,csv "stuff", you know. " """this""","is some","csv ""stuff"", you know."

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.22 ms | 401 KiB | 8 Q