Function:
function parse_csv($csv_string, $delimiter = ",", $skip_empty_lines = true, $trim_fields = true){
    $enc = preg_replace('/(?<!")""/', '!!Q!!', $csv_string);
    $enc = preg_replace_callback(
        '/"(.*?)"/s',
        function ($field) {
            return urlencode($field[1]);
        },
        $enc
    );
    $lines = explode("\n",$enc);
    return array_map(
        function ($line) use ($delimiter, $trim_fields) {
            $fields = $trim_fields ? array_map('trim', explode($delimiter, $line)) : explode($delimiter, $line);
            return array_map(
                function ($field) {
                    return str_replace('!!Q!!', '"', urldecode($field));
                },
                $fields
            );
        },
        $lines
    );
}
Works fine on PHP 5.3.x, but in 5.2.17 I am getting an error:
Parse error: syntax error, unexpected T_FUNCTION in /inc/func.php on line 6
Why is that? How to fix that?
 
     
     
     
    