Looking at your code, this if statement can be kinda awkward to read:
if (!(array_search($file,$ignoredDirectory) > -1)) {
Maybe something simpler like the following would work:
if(!in_array($file, $ignoredDirectory)) {
Other than that, basic pagination would go something like this:
1.) Grab what page you're trying to view from the URL ($_GET['p'] or something)
2.) Decide how many per page there are (you said 10)
3.) Define where to start showing pictures: ($page-1)$perpage [(2-1)10 = 10]
4.) Create your array (or get it from a stored session 😉 ) and start at key previously determined in step 3 and show $perpage images.
Something basic (and probably won't work 100%):
$perpage = 10; // Your 10 images per page
$max = count($files); // How many do we have?
$pages = ceil($max/$perpage); // How many pages to show all images?
$curpage = (!isset($_GET) || empty($_GET['page'])) ? 1 : $_GET['page'];
$start = ($curpage-1)*$perpage;
$end = $start+$perpage;
/**
* Here's some basic info on how the $start value is found:
*
* Page: 1
* (1-1)*10 = 0*10 = 0; First page, start at key 0, go to key 9
* Page: 2
* (2-1)*10 = 1*10 = 10; Second page, start at key 10, go to key 19
* Page: 3
* (3-1)*10 = 2*10 = 20; Third page, start at key 20, go to key 29
*
* So each page starts at "0" and increments to "9" which in fact is 10 numbers ;)
*/
// Show the pagination:
for($i=1; $i<=$pages; $i++) {
if($i != $curpage)
echo '<a href="?page=', $i, '">Page ', $i, '</a>';
if($i == $curpage)
echo '<strong>Page ', $i, '</strong>';
echo ' ';
}
for($i=$start; $i<$last; $i++) {
echo '<img src="', $list['path'], '/', $list['name'], '" alt="" />';
}