PHP不用数据库怎么弄图片分页

来源:百度知道 编辑:UC知道 时间:2024/05/30 17:15:14
PHP不用数据库怎么弄图片分页

图片就放在文件夹里,如何做
请赐代码,谢谢

function listFiles($dir, $ext = '{*.jpg,*.JPG,*.gif,*.GIF,*.PNG,*.png}') {
$alldirs = array();
$dirs = glob($dir . '/'. $ext, GLOB_BRACE);//
if (count($dirs) > 0) {
foreach ($dirs as $d) {
$alldirs[] = $d;
}
}
return $alldirs;
}

function showImgFiles($imgFiles, $pageSize, $image = 'images') {
global $page;
$tempArr = array_chunk($imgFiles, $pageSize);
$k = $page - 1;
echo '<ul style="position: relative;left: -10px;list-style-type: none;width: 780px;overflow: hidden;">';
foreach ($tempArr[$k] as $file) {
echo '<li style="float: left;margin-right: 20px;margin-top: 20px;"><a href=""><img src="'.dirname($_SERVER['SCRIPT_NAME']) . DIRECTORY_SEPARATOR . $image . DIRECTORY_SEPARATOR . basename($file) .'" style="width: 100px;height: 100px;border: 1px solid #ccc" /