<?php
function numfilesindir ($thedir){
if (is_dir ($thedir)){
$scanarray = scandir ($thedir);
for ($i = 0; $i < count ($scanarray); $i++){
if ($scanarray[$i] != "." && $scanarray[$i] != ".."){
if (is_file ($thedir . "/" . $scanarray[$i])){
echo $scanarray[$i] . "<br />";
}
}
}
} else {
echo "Sorry, this directory does not exist.";
}
}
echo numfilesindir ("sample1");
?>
|