I want to display files in my directory in browser. I know that this is possible using @opendir
and readdir
.. But what I want is to limit the numb
Maybe something like this?
$page = 1;
$resultsPerPage = 10;
$files = array();
while(($obj = readdir($dir))) {
$files[] = $obj;
}
$limit = $page * $resultsPerPage;
($limit > count($files)) ? $limit = count($files) : $limit = $limit;
for($i = ($limit - $resultsPerPage); $i < $limit; $i++) {
echo($files[$i];
}
And then have your nav buttons modify the page number.