×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Nilesh Yadav
Added: Jun 7, 2017 12:41 PM
Views: 12
Tags: no tags
  1.  
  2.  function generateCsv($data, $delimiter = ',', $enclosure = '"') {
  3.        $handle = fopen('php://temp', 'r+');
  4.       foreach ($data as $line) {
  5.           fputcsv($handle, $line, $delimiter, $enclosure);
  6.    }
  7.    rewind($handle);
  8.    while (!feof($handle)) {
  9.        $contents .= fread($handle, 8192);
  10.    }
  11.    fclose($handle);
  12.    return $contents;
  13. }