Generate multiple PDF files in loop in php
<p>I want to create multiple pdf files using loop .
I am putting code as below but only one file is generated and all data are written in that file only.How to generate multiple files.</p>

<p>My code is ..</p>

<pre><code>for($i=0;$i&lt;4;$i++)
{

$pli_ids=explode(",",$string);
foreach($pli_ids as $id)
{

    $data[]=array('inv_no'=&gt;$inv_obj-&gt;invoice_number,'Work_order'=&gt;'gandalf','data_type'=&gt;$pli_obj-&gt;data_type_c_pl_c,'subscription'=&gt;'subs1','hs_code'=&gt;'hs1');
}
require_once ('include/pdf/class.ezpdf.php');
$pdf =&amp; new Cezpdf();   
$pdf-&gt;selectFont('include/fonts/Helvetica.afm');

$pdf-&gt;ezSetY(750);
$pdf-&gt;ezText(date('d:M:Y'),14); $pdf-&gt;ezSetY(720);
$pdf-&gt;ezText('To,',14); $pdf-&gt;ezSetY(690);
$pdf-&gt;ezText('Mr. Kumar {contact Name}',14); $pdf-&gt;ezText('Kunal And Company Ltd {Account Name}',14);
$pdf-&gt;ezText('No 6, IInd Floor Marine Drive {contact shipping address}',14);$pdf-&gt;ezSetY(610);
$pdf-&gt;ezText('Mumbai, Pin: 560079',14); $pdf-&gt;ezText('Maharashtra',14);$pdf-&gt;ezText('Mob.:9977200030',14);
$pdf-&gt;ezSetY(550);
$pdf-&gt;ezText(' &lt;c:uline&gt;Sub.: Your order of Export Import News &lt;/c:uline&gt; ',15);
$pdf-&gt;ezSetY(520);  
$pdf-&gt;ezText('Dear Mr. Kumar, {Customer Name}',14);
$pdf-&gt;ezSetY(490);
$pdf-&gt;ezText('Greetings for the day!.',14); $pdf-&gt;ezSetY(460);
$pdf-&gt;ezText('Thanks for being a valuable customer of Infodrive India,we have enclosed the data as follows.');
$pdf-&gt;ezSetY(430);  
$pdf-&gt;ezTable($data,array('inv_no'=&gt;'Inv No.','Work_order'=&gt;'Work Order non','data_type'=&gt;'Data Type','subscription'=&gt;'subscription','hs_code'=&gt;'HS Code'),
    '',
    array('showHeadings'=&gt;2,'shaded'=&gt;1,'xPos'=&gt;'right','xOrientation'=&gt;'left','width'=&gt;400));
$filename = "pdf_".$i;
$pdf-&gt;ezStream(array("Content-Disposition"=&gt;$filename));

}
</code></pre>
