将文本(制表符分隔)转换为PHP关联数组,而不是CSV的此代码? [英] Converting a Text(tab delimited) to PHP associative array, instead of this code for CSV?
本文介绍了将文本(制表符分隔)转换为PHP关联数组,而不是CSV的此代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将我的CSV转换为数组代码为一个文本(制表符分隔)到数组代码。这里是我现有的工作为逗号的...
I would like to convert my CSV to Array code to a Text(tab delimited) to Array block of code. Here is my existing that works for comma's...
$rows = array_map('str_getcsv', $content);
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
$csv[] = array_combine($header, $row);
}
print_r($csv);
什么是最短的转换方式,例如'str_getcsv'接受以逗号分隔的制表符作为默认?
What would be the shortest way to convert for example the 'str_getcsv' to accept tabs over commas as default?
推荐答案
$rows = array_map('str_getcsv', $content, array_fill(0, count($content), "\t"));
这篇关于将文本(制表符分隔)转换为PHP关联数组,而不是CSV的此代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文