◐ Shell
clean mode source ↗

PHP: Directory::read - Manual

(PHP 4, PHP 5, PHP 7, PHP 8)

Directory::readRead entry from directory handle

Description

public function Directory::read(): string|false

Changelog

Version Description
8.0.0 No parameter is accepted. Previously, a directory handle could be passed as argument.

Found A Problem?

matschek at gmx dot de

1 year ago

<?php while ($row=$dir->read())  ?>
// will break as soon as $row can be casted to false, which is the case for a directory named "0"

<?php while (false !== ($row=$dir->read())) ?>
// will do the job as expected

cjcxxh at 163 dot com

3 years ago

use 
while ($row=$dir->read()){
// your code
} 
to get a list of all files and directories. You can definitely use the "for" and other loops.