I have two files one is a tab delimited and one is a csv which is comma seperated and they both get uploaded and I need to combine them into one csv thats sorted...here is my code so far
$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);
}
the test array has the full array of both but i am running into a few problems first the $test array is like this
[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
How do i create a new csv with everything but i need to sort by event name and this format for the test array seems off..any ideas what im doing wrong...