Answers for "php csv auto download"

PHP
0

php csv auto download

<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="sample.csv"');

$list = array (
    array('aaa', 'bbb', 'ccc', 'dddd'),
    array('123', '456', '789'),
    array('"aaa"', '"bbb"')
);


$fp = fopen('php://output', 'w');

foreach ($list as $fields) {
    fputcsv($fp, $fields);
}

fclose($fp);
?>
Posted by: Guest on July-20-2021

Browse Popular Code Answers by Language