title: Update the record in all csv file by php
body: <p>There are 50 csv files. each csv file have the same column's name. some content in the column are the same, some don't.</p>
  
  <pre><code>eg：test1.csv,  example1.csv, hello.csv,  world.csv.......test70.csv. 
  </code></pre>
  
  <p>now, i want to make a change to two column's content.</p>
  
  <p>a, all csv files have a column named <code>qty</code>.  whose rows content are all <code>0</code>. now, i want to change it into <code>888</code> </p>
  
  <p>b, all csv files have a column named <code>img</code>. whose rows content are all</p>
  
  <pre><code> upload/img1.jpg
   upload/img2.jpg
   upload/img3.jpg
   upload/img01.jpg
   upload/img14.jpg
   upload/img01.jpg
  .......
  </code></pre>
  
  <p>If i open each csv file then do a search and replace. i fell it too bored.</p>
  
  <p>Thank you in advance.</p>
  
  <p>the csv file as the following:</p>
  
  <p><a href="http://phplist.xxmn.com/csv.jpg" rel="nofollow">http://phplist.xxmn.com/csv.jpg</a></p>
  
  <p>i want to delete <code>Upload</code> in the image column, change 0 to 888 in the qty column.</p>
  
  <p>i using the file <code>change.php</code> to update the record. 
  the code:</p>
  
  <pre><code>&lt;?php
  $dir    = getcwd();
  $files = array_diff(scandir($dir), array('..', '.','change.php'));
  foreach ($files as $file) {
      if (($handle = fopen($file, "r")) !== FALSE) {
          $new_content = '';
          while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
              //var_dump($data);
             $data[2]=888; 
              $new_content .= implode(',', $data);
              //var_dump($new_content);
          }
         file_put_contents($file, $new_content);
          echo 'down';
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>the code doesn't work how to correct it . thank u</p>
  
  <p>the csv file. 
  <a href="http://phplist.xxmn.com/women.csv" rel="nofollow">http://phplist.xxmn.com/women.csv</a></p>