title: How to combine two csvs/tab delimited into one csv with php?
body: <p>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</p>
  
  <pre><code>$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 &lt; $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 &lt; $num; $c++) {
            $test[$c][] = $data[$c];
          }
      }
      fclose($handle);
  }
  </code></pre>
  
  <p>the test array has the full array of both but i am running into a few problems first the $test array is like this </p>
  
  <pre><code>[0] =&gt; Array
         (
             [0] =&gt; Edit
             [1] =&gt; y
             [2] =&gt; y
             [3] =&gt; y
             [4] =&gt; y
             [5] =&gt; y
             [6] =&gt; y
             [7] =&gt; y
             [8] =&gt; y
             [9] =&gt; y
  [1] =&gt; Array
      (
          [0] =&gt; Event
          [1] =&gt; Carolina Panthers PSL
          [2] =&gt; Florida
          [3] =&gt; Carolina Panthers PSL
          [4] =&gt; Apple
          [5] =&gt; Carolina Panthers PSL
          [6] =&gt; Carolina Panthers PSL
          [7] =&gt; Carolina Panthers PSL
          [8] =&gt; Carolina Panthers PSL
          [9] =&gt; Carolina Panthers PSL
          [10] =&gt; Carolina Panthers PSL
  [2] =&gt; Array
       (
           [0] =&gt; Venue
           [1] =&gt; Bank of America Stadium 
           [2] =&gt; Washington Mutual 
           [3] =&gt; Bank of America Stadium 
           [4] =&gt; Apple Inc
           [5] =&gt; Bank of America Stadium 
           [6] =&gt; Bank of America Stadium 
           [7] =&gt; Bank of America Stadium 
           [8] =&gt; Bank of America Stadium 
           [9] =&gt; Bank of America Stadium 
           [10] =&gt; Bank of America Stadium 
           [11] =&gt; Bank of America Stadium 
           [12] =&gt; Bank of America Stadium
  </code></pre>
  
  <p>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...</p>