我有两个文件,一个是划定一个标签,一个是CSV是逗号分隔,他们都得到上传,我需要将它们组合成一个排序的CSV这就是......这里是我的代码到目前为止如何将两个CSV /制表符分隔到一个CSV与PHP?
$txt = glob('files/*.txt*');
$csv = glob('files/*.csv*');
$test = array();
if (($handle = fopen($csv[0], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
$test[$c][] = $data[$c];
}
}
fclose($handle);
}
if (($handle = fopen($txt[0], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
$test[$c][] = $data[$c];
}
}
fclose($handle);
}
测试阵列既具有全阵列,但我遇到了一些问题,首先是$测试阵列是这样
[0] => Array
(
[0] => Edit
[1] => y
[2] => y
[3] => y
[4] => y
[5] => y
[6] => y
[7] => y
[8] => y
[9] => y
[1] => Array
(
[0] => Event
[1] => Carolina Panthers PSL
[2] => Florida
[3] => Carolina Panthers PSL
[4] => Apple
[5] => Carolina Panthers PSL
[6] => Carolina Panthers PSL
[7] => Carolina Panthers PSL
[8] => Carolina Panthers PSL
[9] => Carolina Panthers PSL
[10] => Carolina Panthers PSL
[2] => Array
(
[0] => Venue
[1] => Bank of America Stadium
[2] => Washington Mutual
[3] => Bank of America Stadium
[4] => Apple Inc
[5] => Bank of America Stadium
[6] => Bank of America Stadium
[7] => Bank of America Stadium
[8] => Bank of America Stadium
[9] => Bank of America Stadium
[10] => Bank of America Stadium
[11] => Bank of America Stadium
[12] => Bank of America Stadium
如何创建的一切新的CSV,但我需要通过事件排序名称和测试阵列的这种格式似乎关闭..任何想法我做错了什么...
我喜欢这个答案....但有没有一种方法来排序数组,但事件名称 – Trace
@Tamer:只是更新答案希望可以帮助 – Clive