The str_getcsv() function is used to parse a CSV string into array. It returns an array with CSV fields in it.
Syntax
str_getcsv(str, delimiter, enclosure, escape
Parameters
str − Parse the input string
delimiter − Set the field delimiter
enclosure −Set the field enclosure character
escape − Set the escape character
Return
The str_getcsv() function returns an array with CSV fields in it.
Example
The following is an example to parse a CSV file into an array −
<?php $res = array_map('str_getcsv', file('new.csv')); ?>
Output
The content of “new.csv” would be visible
demo text