To fix this, I changed the second substr_count to look for an odd number of quotes, as opposed to any quotes at all: <?php function getCSVValues($string, $separator=",") { $elements = explode($separator, $string); for ($i = 0; $i < count($elements); $i++) { $nquotes = substr_count($elements[$i], '"'); if...
Run your php code online; get statistics, vld output and compare output from all versions.