I have an array of id, name, and email. I want to export this to CSV. Anyone Please help me
<?php $delimiter = ","; $filename = "test.csv"; //create a file pointer $f = fopen('php://memory', 'w'); $fields = array('id', 'Name' ,'Email'); fputcsv($f, $fields, $delimiter); $lineData = array('10', 'Ganesh','ganesh@gmail.com'); fputcsv($f, $lineData, $delimiter); fseek($f, 0); //set the header to download the file header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="' . $filename . '";'); //Output the remaining data fpassthru($f); ?>0 0
Please Login to Post the answer