Menu
Riverview Church

STR_GETCSV

Parse a CSV string into an array

SYNTAX

str_getcsv ( string $input [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\\" ]]] ) : array

PARAMETERS

input

The string to parse.

delimiter

Set the field delimiter (one character only).

enclosure

Set the field enclosure character (one character only).

escape

Set the escape character (at most one character). Defaults as a backslash (\). An empty string ("") disables the proprietary escape mechanism.

Note: Usually an enclosure character is escaped inside a field by doubling it; however, the escape character can be used as an alternative. So for the default parameter values "" and \" have the same meaning. Other than allowing to escape the enclosure character the escape character has no special meaning; it isn't even meant to escape itself.

RETURN

Returns an indexed array containing the fields read.

EXAMPLES

INPUT

Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
    [4] => e
)

DELIMITER

Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
    [4] => e
)

ENCLOSURE

Array
(
    [0] => a
    [1] => b
    [2] => c d
    [3] => e
)

ESCAPE

Array
(
    [0] => a
    [1] => b
    [2] => c 'd'
    [3] => e
)

PHP