Question: how to import and export csv file in php?
Answer: Fetch the records from the database.
Create and open a file with writing-only mode using PHP fopen() function.
Set header columns, format as CSV and write it to the opened file using PHP fputcsv() function.
Output data from the database, format as CSV and write it to file.