Candrias77
04-16-2003, 03:40 PM
I have an include which counts how many files are in a directory and displays one of them at random.
Part of my code includes this:
$n='0';
$h = opendir('images/ads/');
while (false !== ($file = readdir($h))) {
if ($file != "." && $file != "..") {
$n++;
}
}
closedir($h);
If a file is in a sub-directory then I need to use a completely different include which has opendir('../images/ads/'); and so on through the directories.
Is there a way to tidy this up so that I can use a single include for all my pages no matter which directory it is in?
Part of my code includes this:
$n='0';
$h = opendir('images/ads/');
while (false !== ($file = readdir($h))) {
if ($file != "." && $file != "..") {
$n++;
}
}
closedir($h);
If a file is in a sub-directory then I need to use a completely different include which has opendir('../images/ads/'); and so on through the directories.
Is there a way to tidy this up so that I can use a single include for all my pages no matter which directory it is in?