note 100033 deleted from function.fputcsv by peehaa

From: Date: Fri, 09 Dec 2016 22:34:36 +0000
Subject: note 100033 deleted from function.fputcsv by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208365@lists.php.net to get a copy of this message
Note Submitter: Guile ---- Here is a way to send csv like echo does : <?php function outputCSV($data) { $outstream = fopen("php://output", 'w'); function __outputCSV(&$vals, $key, $filehandler) { fputcsv($filehandler, $vals, ';', '"'); } array_walk($data, '__outputCSV', $outstream); fclose($outstream); } $mydata = array( array('data11', 'data12', 'data13'), array('data21', 'data22', 'data23'), array('data31', 'data32', 'data23')); outputCSV($mydata); /* Output sent : data11;data12;data13 data21;data22;data23 data31;data32;data23 */ ?> Moreover, this can be nicer with PHP5.3+ closures

« previous php.notes (#208365) next »