How to directly write to CSV using PHP : <p>I'm trying to use 'for loop' and write directly to csv without inserting into database and export as csv file.</p>

<pre><code>&lt;?php 
 require_once('function.php');

 for ($i=0; $i &lt; 6000; $i++) { 
    # code...

   $colum1= generatePassword(5);
   $colum2 = serial_number(5);
   #write directly to csv file 

 }
</code></pre>
