使用php从csv文件中选择数据列
我有类似csv的文件使用php从csv文件中选择数据列,php,csv,Php,Csv,我有类似csv的文件 a, b, c, d 1, 2, 3, 4 5, 6, 7, 8 9, 10, 11, 12 我希望使用php输出如下所示 a 1 5 9 b 2 6 10 c 3 7 11 d 4 8 12 使用此功能 到目前为止,您尝试了什么代码?str_replace('、'、'$string)也许?算了吧,这充其量只是些小事。 <?php $row=str_getcsv(string); $field=array('a','b','c','d'); $n=0; whil
a, b, c, d
1, 2, 3, 4
5, 6, 7, 8
9, 10, 11, 12
我希望使用php输出如下所示
a 1 5 9
b 2 6 10
c 3 7 11
d 4 8 12
使用此功能
到目前为止,您尝试了什么代码?str_replace('、'、'$string)
也许?算了吧,这充其量只是些小事。
<?php
$row=str_getcsv(string);
$field=array('a','b','c','d');
$n=0;
while($n<count($field)) {
echo $field[$n]
foreach($row as $item){
echo $item[$n];
echo ' ';
}
echo '\n';
$nbfield++
}