str_getcsv – PHP String Functions
Syntax :
str_getcsv ( string, separator, enclosure, escape );
Description :
str_getcsv() function parse a CSV string into an array
Parameter :
- string – This is a Required parameter. This is a string which is to be parsed.
- separator – This is an Optional parameter. It defines which character is to be used as field separator in CSV file. Default character is comma ( , )
- enclosure – This is an Optional parameter. It defines which character is to be used as field enclosure character. Default character is ” (double quotes).
- escape – This is an Optional parameter. It defines which character is to be used as escape character. Default character is backslash (\)
Output :
This will return an array containing the fields read.
Related articles : fgetcsv().
str_getcsv() – PHP Functions Example 1 :
<?php $csv = array_map('str_getcsv', file('strFile.csv')); ?>