What are the best practices for handling fields with commas within CSV files in PHP?

When handling fields with commas within CSV files in PHP, the best practice is to enclose the field within double quotes. This ensures that the comma within the field is not mistaken for a delimiter when parsing the CSV file.

$row = 'John,Doe,"New York, USA",30';
$data = str_getcsv($row);

foreach ($data as $value) {
    echo $value . "\n";
}