How can one avoid adding unnecessary enclosures in fputcsv output?

When using fputcsv to output data to a CSV file, unnecessary enclosures may be added around fields that do not require them. To avoid this, you can set the enclosure parameter to an empty string when calling fputcsv. This will prevent any extra enclosures from being added to the output.

$data = array(
    array('John', 'Doe', 'john.doe@example.com'),
    array('Jane', 'Smith', 'jane.smith@example.com'),
);

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

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

fclose($fp);