title: Problem in writing data to CSV file using PHP
body: <p>I have a problem on writing the data to a csv file using php. It doesn't show any error, but it didn't create the file. Can anyone help me with this?</p>
  <pre><code>&lt;?php 
       $mdarray = array();
       $filename = basename(__FILE__, &quot;.php&quot;);
       $f = fopen(&quot;FILES/MonitorStatus.csv&quot;, &quot;r&quot;);
      
       while (($line = fgetcsv($f)) !== false) {
          array_push($mdarray, $line);
       }
       fclose($f);
      
       foreach ($mdarray as $key =&gt; $row) {
          $Status[$key]  = $row[3];
       }
      
       array_multisort($Status, SORT_ASC, $mdarray);
      
       foreach ($mdarray as $line) {
          $fp = fopen('file.csv', 'wb');
          foreach ($line as $cell) {
                  fputcsv($fp, $cell);  
          }
          fclose($fp);
      }
  ?&gt;
  </code></pre>