PHP Function fputcsv

fputcsv — Format line as CSV and write to file pointer


The script I have created generates a csv file, a xls file and sends an email with the information from the database. The fputcsv function formats a line (passed as a fields array), while in the xls.php and email.php files the information is passed as a simple table. To let the user know which file is up to date I have concatenated the time and date, with the file name, using the function date(“Y-m-d H:i:s”); and used the function date_default_timezone_set(‘Europe/London’); to set the date and time, to the user time zone.  As this script was developed for standing orders, I have also created a function changeAddress  in the event the user wants is order deliver to a different address, and a function shipping_service  to select the right shipping code for the order.

For more information check:


  • PHP
  • Includes: index.php, db.php, csv.php, xls.php, email.php


Please check for future updates here or at my gitHub page.