I created a file with fputcsv
$handle = fopen('php://output', 'w+');
// Add the header of the CSV file
fputcsv($handle, array('Name', 'Surname', 'Age', 'Sex'), ';');
// Query data from database
// Add the data queried from database
foreach ($results as $result) {
fputcsv(
$handle, // The file pointer
array(...), // The fields
';' // The delimiter
);
}
file_put_contents('mycsv.csv',fgetcsv($handle), FILE_APPEND);
fclose($handle);
....
I want to save the output on mycsv.csv but the file is empty