Are there any alternatives to scandir() in PHP 4?

In PHP 4, if scandir() is not available, an alternative approach would be to use opendir() and readdir() functions to read the contents of a directory. opendir() opens a directory handle, and readdir() reads the next entry from the directory handle. By looping through the directory entries with readdir(), you can achieve a similar result to scandir().

$dir = "/path/to/directory";
if ($handle = opendir($dir)) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != "..") {
            echo "$entry\n";
        }
    }
    closedir($handle);
}