Skip to content
PHP str_getcsv() Function: Parsing CSV Strings into Arrays

PHP str_getcsv() Function: Parsing CSV Strings into Arrays

The PHP str_getcsv() function parses a CSV‑formatted string into an indexed array, allowing you to specify custom delimiters, enclosure characters, and escape characters, and returns the extracted fields as an array for further processing.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community

str_getcsv() parses a CSV‑formatted string and returns an indexed array of fields.

Signature:

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

Parameters

input : the CSV string to be parsed.

delimiter : the field delimiter character (single character).

enclosure : the character that encloses fields (single character).

escape : the escape character (single character), default is backslash (\).

Return value

An indexed array containing the fields read from the input string.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

parsingPHPCSVstr_getcsv
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.