PHP: How can I explode a string by commas, but not wheres the commas are within quotes?

Since you are using comma seperated values, you can use str_getcsv.

str_getcsv($line, ",", "'");

Will return:

Array
(
    [0] => TRUE
    [1] => 59
    [2] => A large number is 10,000
)

Leave a Comment