- array_push: documentation ( source)
- print_r: documentation ( source)
- range: documentation ( source)
<?php
// Say we have a 74-page file
$num_pages = 74;
// Fill and array.
$pages = range(1, $num_pages);
$sections = array();
for($i = 1; $i <= $pages; $i = $i+2) {
$next = $i+1;
array_push($sections, "pdftk A=the.pdf cat A$i-$next output the_pages_$i-$next.pdf");
}
print_r($sections);