<?php
define( BASE_URL
, '/caminho' );
$imagens = '/1.jpg|/2.jpg|/3.jpg|/4.jpg|/5.jpg|/6.jpg|/7.jpg|/8.jpg';
$aImages = explode( '|', $imagens );
$porPagina = 3;
$total = count( $aImages );
$paginas = ceil( $total / $porPagina );
for( $pagina = 0; $pagina < $paginas; ++$pagina ) {
echo 'Pagina ' . ( $pagina + 1 ) . '<br>' . PHP_EOL;
$offset = $pagina * $porPagina;
for( $item = $offset ; $item < $total && $item < $offset + $porPagina; ++$item ) {
echo '<img src="'.BASE_URL.$aImages[$item].'" ></a>' . PHP_EOL;
}
}
PD9waHAKICAgIGRlZmluZSggQkFTRV9VUkwsICcvY2FtaW5obycgKTsKCiAgICAkaW1hZ2VucyA9ICcvMS5qcGd8LzIuanBnfC8zLmpwZ3wvNC5qcGd8LzUuanBnfC82LmpwZ3wvNy5qcGd8LzguanBnJzsKICAgICRhSW1hZ2VzID0gZXhwbG9kZSggJ3wnLCAgJGltYWdlbnMgKTsKICAgIAogICAgJHBvclBhZ2luYSA9IDM7CiAgICAkdG90YWwgPSBjb3VudCggJGFJbWFnZXMgKTsKICAgIAogICAgJHBhZ2luYXMgPSBjZWlsKCAkdG90YWwgLyAkcG9yUGFnaW5hICk7IAogICAgCiAgICBmb3IoICRwYWdpbmEgPSAwOyAkcGFnaW5hIDwgJHBhZ2luYXM7ICsrJHBhZ2luYSApIHsKICAgICAgIGVjaG8gJ1BhZ2luYSAnIC4gKCAkcGFnaW5hICsgMSApIC4gJzxicj4nIC4gUEhQX0VPTDsKICAgICAgICRvZmZzZXQgPSAkcGFnaW5hICogJHBvclBhZ2luYTsKICAgICAgIGZvciggJGl0ZW0gPSAkb2Zmc2V0IDsgJGl0ZW0gPCAkdG90YWwgJiYgJGl0ZW0gPCAkb2Zmc2V0ICsgJHBvclBhZ2luYTsgKyskaXRlbSApIHsKICAgICAgICAgICBlY2hvICc8aW1nIHNyYz0iJy5CQVNFX1VSTC4kYUltYWdlc1skaXRlbV0uJyIgPjwvYT4nIC4gUEhQX0VPTDsKICAgICAgIH0KICAgIH0K