English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP str_getcsv() Function Usage and Example

PHP String Character String Function Manual

The str_getcsv() function is used to parse CSV strings into arrays.

Syntax

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

Definition and Usage

It is used to parse CSV format field strings and return an array containing the fields read.

Return Value

It returns an indexed array.

Parameter

Serial NumberParameters and Description
1

input

The string to be parsed

2

delimiter

Set the field delimiter character (only one character is allowed), the default value is a comma (,)

3

enclosure

Set the field delimiter character (only one character is allowed), the default value is the double quote (")

4

escape

Set the escape character (only one character is allowed), the default value is the backslash (\)

Online Example

Try the following example to parse CSV format field files and return an array containing the fields read.

<?php
   //Parse CSV format field files and return an array containing the fields read.
   $csv = array_map('str_getcsv', file('Str.csv'));
?>

PHP String Character String Function Manual