Guest User

Untitled

a guest
Mar 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. $file = fopen('demosaved.csv', 'w');
  2.  
  3. // save the column headers
  4. fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
  5.  
  6. // Sample data. This can be fetched from mysql too
  7. $data = array(
  8. array(01523, 'Data 12', 'Data 13', 'Data 14', 'Data 15')
  9. );
  10.  
  11. // save each row of the data
  12. foreach ($data as $row)
  13. {
  14. fputcsv($file, $row);
  15. }
  16.  
  17. // Close the file
  18. fclose($file);
Add Comment
Please, Sign In to add comment