= strlen($record) - 1) { return array($first); } /* Assertion: $record[$end + 1] == ',' */ $rest = substr($record, $end + 2); } else { $end = strpos($record, ','); if ($end === false) { return array($record); } /* Assertion: $end < strlen($record) */ $first = substr($record, 0, $end); $rest = substr($record, $end + 1); } $fields = split_csv_line($rest); array_unshift($fields, $first); return $fields; }