0

I have this code:

$di = new RecursiveDirectoryIterator('MyPics');
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
    echo '<figure class=masonry-brick><img src="'.$filename.'" alt=image class=masonry-img></figure>';
}

I want to make a pagination for this foreach loop.

Note that all of the data is coming from a local folder (I'm not using MySQL) and the folder contains 7000+ pics.

How to make a pagination for this?

jkdev
  • 11,360
  • 15
  • 54
  • 77
  • What have you tried so far, where are you stuck? Could "just" read all files and `array_chunk()` the results – brombeer Jul 23 '19 at 09:45
  • You might want to use LIMIT and OFFSET in your `foreach` loop. See: https://stackoverflow.com/questions/1680136/limit-and-offset-foreach-loops – dcangulo Jul 24 '19 at 06:54

0 Answers0