str_getcsv() 函數用於將 CSV 字符串解析為數組。它返回一個包含 CSV 字段的數組。
用法
str_getcsv(str, delimiter, enclosure, escape
參數
str- 解析輸入字符串
delimiter− 設置字段分隔符
enclosure-設置字段 shell 字符
escape− 設置轉義字符
返回
str_getcsv() 函數返回一個包含 CSV 字段的數組。
示例
以下是將 CSV 文件解析為數組的示例 -
<?php
$res = array_map('str_getcsv', file('new.csv'));
?>
輸出
“new.csv” 的內容是可見的
demo text
相關用法
- PHP str_split()用法及代碼示例
- PHP str_shuffle()用法及代碼示例
- PHP str_word_count()用法及代碼示例
- PHP str_rot13()用法及代碼示例
- PHP str_pad()用法及代碼示例
- PHP str_repeat()用法及代碼示例
- PHP str_ireplace()用法及代碼示例
- PHP str_contains()用法及代碼示例
- PHP str_replace()用法及代碼示例
- PHP str_starts_with()用法及代碼示例
- PHP string rtrim()用法及代碼示例
- PHP strsrt()用法及代碼示例
- PHP string printf()用法及代碼示例
- PHP string ord()用法及代碼示例
- PHP string join()用法及代碼示例
- PHP strtolower()用法及代碼示例
- PHP stream_get_filters()用法及代碼示例
- PHP strchr()用法及代碼示例
- PHP string sha1()用法及代碼示例
- PHP strrchr用法及代碼示例
注:本文由純淨天空篩選整理自Arjun Thakur大神的英文原創作品 str_getcsv() function in PHP。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。