function fileTree($dir) { $d = dir($dir); $arDir = array(); while (false !== ($entry = $d->read())) { if($entry != '.' && $entry != '..' && !(is_dir($dir.$entry))) $arDir[$entry] = $dir.$entry; } $d->close(); return ( $arDir ); } $dir = "books/".$_GET['bn']."/"; $arDirTree = fileTree($dir); $no_of_pages= count($arDirTree); ?>