<?php

$results	 = array(
	array("ELLIE", "MORRIS", "J1 RTW"),
	array("GRAHAME", "ROSE", "KNL4 6TR"),
	array("Timothy", "Nanan", "H1 RON")
);
$fileName	 = 'contacts-' . date("Y-m-d-H-i-s", time()) . '.csv';

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename={$fileName}");
header("Expires: 0");
header("Pragma: public");

$fh = @fopen("php://output", 'w');

$headerDisplayed = false;

fputcsv($fh, array("first name", "surname", "vehicle registration"));
foreach ($results as $data) {
	fputcsv($fh, $data);
}
// Close the file
fclose($fh);
// Make sure nothing else is sent, our file is done
exit;
