note 61102 added to function.directoryiterator-construct

From: Date: Wed, 25 Jan 2006 18:36:56 +0000
Subject: note 61102 added to function.directoryiterator-construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-102439@lists.php.net to get a copy of this message
We can now replace the old fashioned way of listing the content from a directory! the old way: <?php if ($handle = opendir('/home/fernando/temp')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { print "$file <br />"; } } closedir($handle); } ?> the new way: <?php $dir = new DirectoryIterator('/home/fernando/temp'); while($dir->valid()) { if(!$dir->isDot()) { print $dir->current()."<br />"; } $dir->next(); } ?> ---- Server IP: 64.246.30.37 Probable Submitter: 201.3.195.252 ---- Manual Page -- http://www.php.net/manual/en/function.directoryiterator-construct.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61102 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61102&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61102&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102439) next »