title: fgetcsv - Add Quotes to fields that do not have quotes
body: <p>I have a text file (its comma delimited with some fields wrapped around in double quotes) when I parse through it using this:</p>
  
  <pre><code>if (($handle = fopen('C:\tester\fake.txt', "r")) !== FALSE) {
      while (($data = fgetcsv($handle, ",")) !== FALSE) {
          $num = count($data);
          //echo "&lt;p&gt; $num fields in line $row: &lt;br /&gt;&lt;/p&gt;\n";
          $row++;
          for ($c=0; $c &lt; $num; $c++) {
              echo $data[$c] . "&lt;br /&gt;\n";
          }
      }
      fclose($handle);
  }
  </code></pre>
  
  <p>It shows each field not to have quotes, does the fgetcsv remove this automatically?</p>
  
  <p>How can I get it to show fields that do not have quotes and add quotes to them and then save the file? Possible?</p>
  
  <p>Thanks all</p>
  
  <h2>Update</h2>
  
  <p>I have just tried the fputcsv and I find the file written doesn't have quotes around the fields, only very few, less than the initial file had! What am I doing wrong?</p>
  
  <pre><code>$row = 1;
  $newfile = fopen('C:\new-file.txt', "w");
  
  if (($handle = fopen('C:\fake.txt', "r")) !== FALSE) {
      while (($data = fgetcsv($handle, ",")) !== FALSE) {
          $num = count($data);
              fputcsv($newfile, $data, ',', '"');
      }
      fclose($handle);
      fclose($newfile);
  }
  </code></pre>