我有一个 php 函数可以让我将 csv 列(COLUMN NOT LINE)读取到数组或字符串中?
提前致谢。
最佳答案
$csv = array_map("str_getcsv", file("data.csv"));
$header = array_shift($csv);
// Seperate the header from data
$col = array_search("Value", $header, true);
foreach ($csv as $row) {
$array[] = $row[$col];
}
关于PHP 将 csv 列读入数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17653946/