Want create site? Find Free WordPress Themes and plugins.

This post i will explains, how to create and download a CSV file using PHP instead of displaying.

<?php
  // Creates a new csv file and store it in tmp directory
  $new_csv = fopen('/tmp/my_csv.csv', 'w');
  fputcsv($new_csv, $row);
  fclose($new_csv);
  // output headers so that the file is downloaded rather than displayed
  header("Content-type: text/csv");
  header("Content-disposition: attachment; filename = my_csv.csv");
  readfile("/tmp/my_csv.csv");
?>

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

Did you find apk for android? You can find new Free Android Games and apps.

Posted by Abhay Kumar

I am Abhay Kumar from New Delhi (India). I'm working as a Web Developer from last 3+ years. You can follow me on Twitter, Facebook or Google+.