php - How to use Glob Brace for listing only folders with pagination -
i want know , how can use php's glob brace function open dir , scan folders , , show pagination (page1,page2,etc). , how limit results per page?
based on: pagination of php glob page
$folders = glob("*", glob_onlydir); usort($folders, function ($a, $b) { return filemtime($b) - filemtime($a); }); $record_count = 20; $total_pages = ceil(count($folders)/$record_count); $page = $_request['page']; ///make dyanamic :: page num $offset = ($page-1)*$record_count; $folders_filter = array_slice($folders, $offset,$record_count); foreach ($folders_filter $folder) { echo "$folder <br/>"; } if($total_pages > 1){ if($page != 1){ echo '<a href="thispage.php?page='.($page-1).'">prev</a>'; } if($page != $total_pages){ echo '<a href="thispage.php?page='.($page+1).'">next</a>'; } }
Comments
Post a Comment