title: PHP Replace all values in the third column in a csv file
body: <p>I am trying to replace some hyperlinks in a csv file, like this one: 
  [<a href="https://assets.suredone.com/683987/media-pics/6164307j-gabriel-61643-proguard-steel-shock-absorber-for-select-chevrolet-gmc-models.jpg" rel="nofollow noreferrer">https://assets.suredone.com/683987/media-pics/6164307j-gabriel-61643-proguard-steel-shock-absorber-for-select-chevrolet-gmc-models.jpg</a>. Here is my code:][1]. Here is my code:</p>
  
  <pre><code>&lt;?php
  $in_file = 'gabriel-images-urls.csv';
  $out_file = 'results.csv';
  
  $fd = fopen($in_file, "r");
  
  $new_array= array();
  $toBoot= array();
  
  while ($data = fgetcsv($fd)) {
  echo '&lt;pre&gt;';
  if (strpos($data[2],'media-pics') !== false) {
  
  $data[2]=str_replace('media-pics','media-photos',$data[2]);
  fputcsv($fd, $data);
  // echo $output;
  
  }
  
  }
  ?&gt;
  </code></pre>
  
  <p>The new link for example must look like this:[1]<a href="https://assets.suredone.com/683987/media-photos/6164307j-gabriel-61643-proguard-steel-shock-absorber-for-select-chevrolet-gmc-models.jpg" rel="nofollow noreferrer">https://assets.suredone.com/683987/media-photos/6164307j-gabriel-61643-proguard-steel-shock-absorber-for-select-chevrolet-gmc-models.jpg</a>. The goal is he "media-pics" substring to be replaced with "media-photos". At this point nothing happens in the file. I think this is because the file is open only for reading but I am not sure.</p>