What are the advantages of storing form data in a CSV file over an Excel file when working with PHP?

When working with form data in PHP, storing the data in a CSV file is advantageous over an Excel file because CSV files are simpler and lighter in terms of file size. CSV files are also easier to manipulate programmatically in PHP compared to Excel files. Additionally, CSV files can be easily imported and exported in various applications and programming languages.

// Storing form data in a CSV file
$data = [
    ['Name', 'Email', 'Phone'],
    ['John Doe', 'john@example.com', '1234567890'],
    ['Jane Smith', 'jane@example.com', '0987654321']
];

$fp = fopen('form_data.csv', 'w');

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

fclose($fp);