title: Output of fputcsv can not be parsed correctly by fgetcsv/str_getcsv
body: <p>I dont know if this is my mistake or bug of PHP? I have this code:</p>
  
  <pre><code>&lt;?php
  
  if (!function_exists('str_putcsv')) {
      function str_putcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\') {
          $fp = fopen('php://temp', 'r+b');
          fputcsv($fp, $input, $delimiter, $enclosure, $escape);
          rewind($fp);
          $data = rtrim(stream_get_contents($fp), "\n");
          fclose($fp);
          return $data;
      }
  }
  
  $a[] = 'Bro the';
  $a[] = "Bro\nther";
  $a[] = 'Bro"ther';
  $a[] = 'Bro""ther';
  $a[] = 'Bro\ther';
  $a[] = '12345678';
  $a[] = '12345678\\';
  $a[] = 'Bro ther';
  $a[] = '12345678\\\\';
  $a[] = '"12345678"';
  
  print $x1 = print_r($a, 1);
  
  
  $s=str_putcsv($a,';','"','\\');
  
  
  print_r($s);
  print "\n";
  
  $a=str_getcsv($s,";",'"','\\');
  print $x2 = print_r($a ,1);
  
  print 'same? ' . ($x1==$x2);
  print "\n";
  </code></pre>
  
  <p>Output of the code:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Bro the
      [1] =&gt; Bro
  ther
      [2] =&gt; Bro"ther
      [3] =&gt; Bro""ther
      [4] =&gt; Bro\ther
      [5] =&gt; 12345678
      [6] =&gt; 12345678\
      [7] =&gt; Bro ther
      [8] =&gt; 12345678\\
      [9] =&gt; "12345678"
  )
  "Bro the";"Bro
  ther";"Bro""ther";"Bro""""ther";"Bro\ther";12345678;"12345678\";"Bro ther";"12345678\\";"""12345678"""
  Array
  (
      [0] =&gt; Bro the
      [1] =&gt; Bro
  ther
      [2] =&gt; Bro"ther
      [3] =&gt; Bro""ther
      [4] =&gt; Bro\ther
      [5] =&gt; 12345678
      [6] =&gt; 12345678\";Bro ther"
      [7] =&gt; 12345678\\
      [8] =&gt; "12345678"
  )
  same? 
  </code></pre>
  
  <p>The result array from fgetcsv is different from source array, which should be same. Am I doing wrong?
  Another question:</p>
  
  <ol>
  <li>Why fputcsv dont escape " to \" and dont escape \ to \\</li>
  <li>Why fgetcsv/str_getcsv dont replace \\ to \</li>
  </ol>
  
  <p>I'm using PHP 5.6.4-4ubuntu6.4</p>
  
  <p>Thanks</p>