What are the limitations of reading directories on external servers in PHP?

When reading directories on external servers in PHP, you may encounter limitations due to security restrictions or permissions set on the server. To solve this issue, you can use the PHP function `scandir()` to read the contents of a directory on the external server. Make sure that the server has the necessary permissions to access the directory you are trying to read.

$directory = 'ftp://example.com/path/to/directory/';
$contents = scandir($directory);

foreach($contents as $file){
    echo $file . "<br>";
}