Definition
The str_getcsv() function parses a string for fields in CSV format and returns an array containing the fields read.
Syntax
str_getcsv(string, separator, enclosure, escape)
Parameters
| Parameter | Description |
|---|---|
string |
Required. Specifies the string to parse. |
separator |
Optional. A character that specifies the field separator. Default is comma (,). |
enclosure |
Optional. A character that specifies the field enclosure character. Default is ". |
escape |
Optional. A character that specifies the escape character. Default is backslash (\). |
Example
<?php
$str = "New York,Salt Lake,Tokyo";
$arr = str_getcsv($str);
print_r($arr);