PHP | FilesystemIterator next() Function Last Updated : 26 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The FilesystemIterator::next() function is an inbuilt function in PHP which is used to move to the next file element. Syntax: void FilesystemIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the FilesystemIterator::next() function in PHP: Program 1: php <?php // Create new file system iterator $fileItr = new FilesystemIterator(dirname(__FILE__)); // Check for validity of file iterator while ($fileItr->valid()) { // Check for directory if ($fileItr->isDir()) { // Display the filename echo $fileItr->getFilename() . "<br>"; } // Move to the next element $fileItr->next(); } ?> Output: dashboard img webalizer xampp Program 2: php <?php // Create new file system iterator $fileItr = new FilesystemIterator(dirname(__FILE__), FilesystemIterator::KEY_AS_FILENAME); // Loop runs while file iterator is valid while ($fileItr->valid()) { // Check if file iterator is not directory if (!$fileItr->isDir()) { // Display the key element echo $fileItr->key() . "<br>"; } // Move to the next element $fileItr->next(); } ?> Output: applications.html bitnami.css favicon.ico geeks.PNG gfg.php index.php Sublime Text Build 3211 x64 Setup.exe Note: The output of this function depends on the content of server folder. Reference: https://www.php.net/manual/en/filesystemiterator.next.php Comment More infoAdvertise with us Next Article PHP | FilesystemIterator next() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Iterators Similar Reads PHP | FilesystemIterator key() Function The FilesystemIterator::key() function is an inbuilt function in PHP which is used to retrieve the key for the current file. Syntax: string FilesystemIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the pathname or filename depending 1 min read PHP | FilesystemIterator getFlags() Function The FilesystemIterator::getFlags() function is an inbuilt function in PHP which is used to get the handling flags. Syntax: int FilesystemIterator::getFlags( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an integer value representing the set of f 1 min read PHP | FilesystemIterator rewind() Function The FilesystemIterator::rewind() function is an inbuilt function in PHP which is used to rewinds back to the beginning of the file. Syntax: void FilesystemIterator::rewind( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below p 2 min read PHP | FilesystemIterator current() Function The FilesystemIterator::current() function is an inbuilt function in PHP which is used to returns the file information of the current element. Syntax: mixed FilesystemIterator::current( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the filename, 1 min read PHP | DirectoryIterator next() Function The DirectoryIterator::next() function is an inbuilt function in PHP which is used to move forward to the next DirectoryIterator item. Syntax: void DirectoryIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below p 1 min read PHP | FilesystemIterator setFlags() Function The FilesystemIterator::setFlags() function is an inbuilt function in PHP which is used to set the handling flags. Syntax: void FilesystemIterator::setFlags( int $flags ) Parameters: This function accepts single parameter $flags which holds the handling flags to set. Return Value: This function does 1 min read PHP | FilesystemIterator __construct() Function The FilesystemIterator::__construct() function is an inbuilt function in PHP which is used to construct a new filesystem iterator. Syntax: public FilesystemIterator::__construct( string $path, int $flags ) Parameters: This function accepts two parameters as mentioned above and described below: $path 2 min read PHP | ArrayIterator next() Function The ArrayIterator::next() function is an inbuilt function in PHP which is used to move the iterator to the next entry. Syntax: void ArrayIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate t 1 min read PHP | AppendIterator next() Function The AppendIterator::next() function is an inbuilt function in PHP which is used to move the element into the next element. Syntax: void AppendIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustr 2 min read PHP | CachingIterator next() Function The CachingIterator::next() function is an inbuilt function in PHP which is used to move the iterator to the forward. Syntax: void CachingIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate 1 min read Like