如何解析在列中有多行数据的PHP中的csv [英] How to parse csv in PHP having multiline data in a column
本文介绍了如何解析在列中有多行数据的PHP中的csv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑这样的CSV文件
item1,"description 1"
item2,"description 2"
item3,"description 3
description 3 continues on new line"
item4,"description 4"
应该像这样解析
item1,"description 1"
item2,"description 2"
item3,"description 3 description 3 continues on new line"
item4,"description 4"
有没有办法在PHP中解析这个CSV,它有多行值?
Is there a way to parse this CSV in PHP which has multiline values?
推荐答案
a href =http://php.net/fgetcsv> fgetcsv
应该能够正确解析此内容。
I wouldn不建议这样做,手动,有很多这样的陷阱解析CSV。
fgetcsv
should be able to properly parse this.
I wouldn't recommend doing this by hand anyway, there are many such gotchas in parsing CSV.
这篇关于如何解析在列中有多行数据的PHP中的csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文