How can I make a PHP 'foreach' loop repeat entire line? -
my objective allow users select check boxes , when click submit combines pdfs 1 pdf. (each check box has pdf value).
<?php include 'pdfmerger.php'; $pdf = new pdfmerger; $pdf1 = "/path/pdf1.pdf"; $pdf2 = "/path/pdf2.pdf"; ?> <form action="#" method="post"> <input type="checkbox" name="check_list[]" value="<?php echo $pdf1 ?>"><label>pdf one</label><br/> <input type="checkbox" name="check_list[]" value="<?php echo $pdf2 ?>"><label>pdf two</label><br/> <input type="submit" name="submit" value="submit"/> </form> <?php if(!empty($_post['check_list'])){ foreach($_post['check_list'] $selected){ $pdf->addpdf($selected); } } ?> <?php ob_start(); if(isset($_post['submit'])){ $pdf->merge('download', 'test223.pdf'); } ?>
i not php expert @ all, sure there many errors in above code. problem lies 'foreach" area think. repeats $selected part.. not entire line each pdf.
so, if users select 1 box.. works fine. if select more 1 puts pdf path 1 after other in code , merger program can't use that.
//to visualize issue.. need loop produce this: $pdf->addpdf("/path/pdf1.pdf"); $pdf->addpdf("/path/pdf2.pdf"); $pdf->addpdf("/path/pdf3.pdf"); etc... //it producing: $pdf->addpdf("/path/pdf1.pdf/path/pdf2.pdf/path/pdf3.pdf");
thank in advance.
Comments
Post a Comment