GoLang str_getcsv

request it (397)
GoLang replacement for PHP's str_getcsv [edit | history]



Do you know a GoLang replacement for PHP's str_getcsv? Write it!

PHP str_getcsv

PHP original manual for str_getcsv [ show | php.net ]

str_getcsv

(PHP 5 >= 5.3.0, PHP 7)

str_getcsv Parse a CSV string into an array

Description

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

Parses a string input for fields in CSV format and returns an array containing the fields read.

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 (one character only). Defaults as a backslash (\)

Note: Usually an enclosure character is escpaped 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 Values

Returns an indexed array containing the fields read.

See Also

  • fgetcsv() - Gets line from file pointer and parse for CSV fields