How can I use the fputcsv function to write an array to a CSV file in PHP? Example code: - Biz Tech

How can I use the fputcsv function to write an array to a CSV file in PHP? Example code:

Listen
$file = fopen("example.csv", "w");

$data = array(
    array("Name", "Age", "Email"),
    array("John Doe", 30, "johndoe@example.com"),
    array("Jane Smith", 25, "janesmith@example.com"),
);

foreach ($data as $row) {
    fputcsv($file, $row);
}

fclose($file);