fputcsv is a PHP function that formats a line (passed as a fields array) as CSV and writes it (terminated by a newline) to the specified file handle.
<?php $filename="backup_".date('m/d/Y', time()).".csv"; header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment;…
php fputcsv