scandir is PHP5, so to do the same in PHP4 you would need a different approach, which means a couple more lines of code.
I've done this some time ago, but I couldn't find my own code at the moment, so I found a similar code
here :
[PHP]
<?php
// declare the folder
$ourDir = "/home/public_html/folderName";
// prepare to read directory contents
$ourDirList = @opendir($ourDir);
// loop through the items
while ($ourItem = readdir($ourDirList))
{
// check if it is a directory
if (is_dir($ourItem))
{
echo "directory: $ourItem <br />";
}
// check to see if it is a file
if (is_file($ourItem))
{
echo "file: $ourItem <br />";
}
}
closedir($ourDirList);
?>
[/PHP]
This should work in PHP4 as well as PHP5.