title: php strip or delete extra columns/comma delimited for mysql
body: <p>I'm having an issue with columns/fields not matching when I try to insert the data into mysql.  My current table has 306 columns/fields (its not normalized/optimized yet, but it will be in the future).  The first 306 fields are always correct data and needs to be saved in mysql.  Everything after the first 306 fields can be deleted/purged.  This is my php code for injection:</p>
  
  <pre><code>$source = "http://www.aviationweather.gov/adds/dataserver_current/current/tafs.cache.csv";
  
  $file = file($source);
      for($i = 0; $i &lt; 6; $i++) array_shift($file);
          foreach($file as $line) {
              $csv  = str_getcsv($line);
              if (!$db-&gt;query("INSERT INTO tafs VALUES('" . implode("','", $csv) . "');")) {
              } else { 
              $n++;           
              }
          }
  </code></pre>
  
  <p>The csv source file is updated every minute, and sometimes it will have the correct 306 columns, other times it will have 1500-2000 for no apparent reason.  This breaks my implode horribly and since the data is highly dynamic I can't use the rtrim feature =\  ... </p>
  
  <p>Anyone have any ideas?  I've been stuck for awhile now... spent an hour searching for php commands/examples, and about 2 hours for mysql commands... Am I missing something?</p>
  
  <p>Thanks for any and all support, have a happy 4th of July!</p>
  
  <p>-Mikael</p>