Skip to content

Instantly share code, notes, and snippets.

@alokstha1
Created August 25, 2017 08:34
Show Gist options
  • Save alokstha1/b32035504020a7b2bac0cfc585ba6bce to your computer and use it in GitHub Desktop.
Save alokstha1/b32035504020a7b2bac0cfc585ba6bce to your computer and use it in GitHub Desktop.
Create an exporter
<?php
header('Content-Encoding: Windows-1252');
header('Content-Type: text/csv; charset=Windows-1252');
header('Content-Disposition: attachment; filename='.$filename.'.csv' );//$filename as name of a file that will be downloaded
$output = fopen($filepath, 'w');//$filepath as path to the directory where the file will reside.
fputcsv($output, array('arrays of column header'));
fputcsv($output, $insert_array);
fclose($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment