php解析CSV字符串,源码如下:
<?php
function parse_csv($string, $delim = \',\', $quote=\'\"\') {
$new = str_replace(\"{$quote}{$quote}\", $quote, $string);
$matches = array();
preg_match_all(\"/\\s*({$quote}?)(.*?)\\\\1\\s*(?:{$delim}|$)/\",
$new, $matches);
array_pop($matches[2]);
return $matches[2];
}
/* http://www.manongjc.com/article/1309.html */
$str = \'c \"s\"\"v\"\"\",\"s\", \"f\\ny\" \';
$values = parse_csv($str);
echo \'<pre>\';
print_r($values);
echo \'</pre>\';
?> 继续阅读与本文标签相同的文章
-
华为高管彭博:正与美国公司就授权5G平台展开初期谈判
2026-05-14栏目: 教程
-
微信曝光新功能,超好用,再也不用担心被刷屏
2026-05-14栏目: 教程
-
Verizon为美国多座大型体育场馆提供了5G网络覆盖
2026-05-14栏目: 教程
-
别人加薪你加班,偷偷告诉你 6 个Word小技巧,比加薪都管用!
2026-05-14栏目: 教程
-
华为轮值董事长郭平:虚拟技术创造现实价值
2026-05-14栏目: 教程
