CSV 解析 +多维数组
59516,?O?L?h,27,80,67,13,1,84.6,40,4,1,32632,??,3,5,32640,AES,3,5,32210,\
???i?Z??,1,1.2,32263,?,1,1.2,3?T,1,1.2,32104,,1,1,40012,??,1,0.8
我如何分解/列出这一行并提取包含五个字符数字的任何字段以及紧邻其前面的字段?
即 $data['59516']['i']
将包含一个数组
(32632=>1, 32640=>5, 32210=>5, 32263=>1.2,32104=>2, 40012=>1)
59516,?O?L?h,27,80,67,13,1,84.6,40,4,1,32632,??,3,5,32640,AES,3,5,32210,\
???i?Z??,1,1.2,32263,?,1,1.2,3?T,1,1.2,32104,,1,1,40012,??,1,0.8
How would I explode/list this line and pull any field that contains a five-character number and the field immediately preceding it?
i.e. $data['59516']['i']
would contain an array with
(32632=>1, 32640=>5, 32210=>5, 32263=>1.2,32104=>2, 40012=>1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定我完全理解你的问题,但听起来你想要类似的东西:
Not sure i fully understand your question, but it sounds like you want something like:
(?<=,)(\d+),(\d{5})
$matches[1]
具有值,而$matches[ 2]
有你的钥匙。(?<=,)(\d+),(\d{5})
The
$matches[1]
has the value and the$matches[2]
has your key.