public static function lineIsOpenQuoted($line, $quote, $escape)
    {
        // Returns TRUE if line is valid
        $pos        = 0;
        $quote_open = false;
        $esc_len    = strlen($escape);

        for (; $pos < strlen($line); ++ $pos) {
            $char = $line[$pos];

            // If the character is part of an escape squence, advance the string.
            if (substr($line, $pos, $esc_len) == $escape) {
                $pos += $esc_len - 1; // Subtract one because we advance on loop start.
                continue;
            }

            // Otherwise, toggle the quote flag if this is a quote character
            if ($char == $quote)
                $quote_open = !$quote_open;

            // Continue if the character is anything else.
        }

        if ($quote_open)
            return true;
        else
            return false;
    }
public static function lineIsOpenQuoted($line, $quote, $escape)
    {
        // Returns TRUE if line is valid
        $pos        = 0;
        $quote_open = false;
        $esc_len    = strlen($escape);

        for (; $pos < strlen($line); ++ $pos) {
            $char = $line[$pos];

            // If the character is part of an escape squence, advance the string.
            if (substr($line, $pos, $esc_len) == $escape) {
                $pos += $esc_len - 1; // Subtract one because we advance on loop start.
                continue;
            }

            // Otherwise, toggle the quote flag if this is a quote character
            if ($char == $quote)
                $quote_open = !$quote_open;

            // Continue if the character is anything else.
        }

        if ($quote_open)
            return true;
        else
            return false;
    }
public static function lineIsOpenQuoted ( $ line , $ quote , $ escape ) { // Returns TRUE if line is valid $ pos = 0 ; $ quote_open = false ; $ esc_len = strlen ( $ escape ) ; for ( ; $ pos < strlen ( $ line ) ; ++ $ pos ) { $ char = $ line [ $ pos ] ; // If the character is part of an escape squence, advance the string. if ( substr ( $ line , $ pos , $ esc_len ) == $ escape ) { $ pos += $ esc_len - 1 ; // Subtract one because we advance on loop start. continue ; } // Otherwise, toggle the quote flag if this is a quote character if ( $ char == $ quote ) $ quote_open = ! $ quote_open ; // Continue if the character is anything else. } if ( $ quote_open ) return true ; else return false ; }
Determines if a line is "open-quoted" and continues to the next line.

Most useful for parsing CSV files.

@param string $line   The line to examine
@param string $quote  The quote character (must be one character)
@param string $escape The escape character or character set

@return void
Determines if a line is open - quoted and continues to the next line .