fork(2) download
  1. <?php
  2.  
  3. define('__CSV_DELIMITER__', ';');
  4. define('__CSV_ENCLOSURE__', '"');
  5. define('__CSV_ESCAPE__', '\\');
  6.  
  7. $csv_parsed = str_getcsv('"id";"foreign_id";"name";"published";created;"šomething šašy";"description"', __CSV_DELIMITER__, __CSV_ENCLOSURE__, __CSV_ESCAPE__);
  8.  
  9. function __outputCSV(&$vals, $key, $filehandler) {
  10. fputcsv($filehandler, $vals, __CSV_DELIMITER__, __CSV_ENCLOSURE__, __CSV_ESCAPE__);
  11. }
  12. function outputCSV($data) {
  13. $outstream = fopen("php://output", 'w');
  14. array_walk($data, '__outputCSV', $outstream);
  15. fclose($outstream);
  16. }
  17.  
  18. //EXAMPLE USAGE&OUTPUT:
  19. //echo "<pre>"; //uncomment for user-readability
  20. outputCSV([$csv_parsed, $csv_parsed, $csv_parsed]);
  21. //echo "</pre>"; //uncomment for user-readability
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
id;foreign_id;name;published;created;"šomething šašy";description
id;foreign_id;name;published;created;"šomething šašy";description
id;foreign_id;name;published;created;"šomething šašy";description