hello,
I created small script with foreach loop. This script is use for to search files in directory. Everything is working perfectly, now I want to add pagination so that it can split display i.e.: 1,2,3 NEXT >>… Here is my code:
[php]
<?php function ListFiles($dir) { if($dh = opendir($dir)) { $files = Array(); $inner_files = Array(); while($file = readdir($dh)) { if($file != "." && $file != ".." && $file[0] != '.') { if(is_dir($dir . "/" . $file)) { $inner_files = ListFiles($dir . "/" . $file); if(is_array($inner_files)) $files = array_merge($files, $inner_files); } else { array_push($files, $dir . "/" . $file); } } } closedir($dh); return $files; } } ?> <?php function count_deep($folder, $filetype = "*", $count_folders = false) { $c = 0; $dirs = array($folder); while($dir = each($dirs)) { foreach(glob($dir[1]."/*", GLOB_ONLYDIR) as $filename) { $dirs[] = $filename; } $c += count(glob($dir[1]."/".$filetype)); } if(!$count_folders && ($filetype == "*")) $c -= (count($dirs)-1); return $c; } echo ""; echo count_deep("backup"); echo " | |
" ; echo $_SESSION['calc'] ; echo " |
"; $i = 1; foreach (ListFiles('backup') as $key=>$file){ $num= $i++; echo "
$num</strong | $file | (". date ("F d Y H:i:s", filemtime($file)) ; echo ") | " . humanSize(filesize($file)) ; echo " |
[/php]