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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -