public static function csvFields(string $line, string $delimiter = ','): array
    {
        if (trim($line) === '') {
            return [];
        }
        $fields = [];
        $parts = str_getcsv($line, $delimiter);
        if ($parts !== null && count($parts) > 0) {
            foreach ($parts as $part) {
                $part = trim($part);
                if (substr($part, 0, 1) === '"' || substr($part, 0, 1) === '\'') {
                    $part = substr($part, 1);
                }
                if (substr($part, -1) === '"' || substr($part, -1) === '\'') {
                    $part = substr($part, 0, -1);
                }
                if ($part !== '') {
                    $fields[] = $part;
                }
            }
        }
        return $fields;
    }
public static function csvFields(string $line, string $delimiter = ','): array
    {
        if (trim($line) === '') {
            return [];
        }
        $fields = [];
        $parts = str_getcsv($line, $delimiter);
        if ($parts !== null && count($parts) > 0) {
            foreach ($parts as $part) {
                $part = trim($part);
                if (substr($part, 0, 1) === '"' || substr($part, 0, 1) === '\'') {
                    $part = substr($part, 1);
                }
                if (substr($part, -1) === '"' || substr($part, -1) === '\'') {
                    $part = substr($part, 0, -1);
                }
                if ($part !== '') {
                    $fields[] = $part;
                }
            }
        }
        return $fields;
    }
public static function csvFields ( string $ line , string $ delimiter = ',' ) : array { if ( trim ( $ line ) === '' ) { return [ ] ; } $ fields = [ ] ; $ parts = str_getcsv ( $ line , $ delimiter ) ; if ( $ parts !== null && count ( $ parts ) > 0 ) { foreach ( $ parts as $ part ) { $ part = trim ( $ part ) ; if ( substr ( $ part , 0 , 1 ) === '"' || substr ( $ part , 0 , 1 ) === '\'' ) { $ part = substr ( $ part , 1 ) ; } if ( substr ( $ part , - 1 ) === '"' || substr ( $ part , - 1 ) === '\'' ) { $ part = substr ( $ part , 0 , - 1 ) ; } if ( $ part !== '' ) { $ fields [ ] = $ part ; } } } return $ fields ; }
Get CSV fields. Removes ' and ".

@param string $line
@param string $delimiter Default ','.
@return string[]
Get CSV fields . Removes and .