fork(3) download
  1. <?php
  2. define( BASE_URL, '/caminho' );
  3.  
  4. $imagens = '/1.jpg|/2.jpg|/3.jpg|/4.jpg|/5.jpg|/6.jpg|/7.jpg|/8.jpg';
  5. $aImages = explode( '|', $imagens );
  6.  
  7. $porPagina = 3;
  8. $total = count( $aImages );
  9.  
  10. $paginas = ceil( $total / $porPagina );
  11.  
  12. for( $pagina = 0; $pagina < $paginas; ++$pagina ) {
  13. echo 'Pagina ' . ( $pagina + 1 ) . '<br>' . PHP_EOL;
  14. $offset = $pagina * $porPagina;
  15. for( $item = $offset ; $item < $total && $item < $offset + $porPagina; ++$item ) {
  16. echo '<img src="'.BASE_URL.$aImages[$item].'" ></a>' . PHP_EOL;
  17. }
  18. }
  19.  
Success #stdin #stdout #stderr 0.02s 52472KB
stdin
Standard input is empty
stdout
Pagina 1<br>
<img src="/caminho/1.jpg" ></a>
<img src="/caminho/2.jpg" ></a>
<img src="/caminho/3.jpg" ></a>
Pagina 2<br>
<img src="/caminho/4.jpg" ></a>
<img src="/caminho/5.jpg" ></a>
<img src="/caminho/6.jpg" ></a>
Pagina 3<br>
<img src="/caminho/7.jpg" ></a>
<img src="/caminho/8.jpg" ></a>
stderr
PHP Notice:  Use of undefined constant BASE_URL - assumed 'BASE_URL' in /home/oZpxYE/prog.php on line 2