note 107224 added to function.readdir
| From: | (TheCraw) | Date: | Mon, 23 Jan 2012 01:09:25 +0000 |
| Subject: | note 107224 added to function.readdir | ||
| Groups: | php.notes php.notes | ||
| Request: | Send a blank email to php-notes+get-185706@lists.php.net to get a copy of this message | ||
If you wish to exclude files starting with a period, this code works for that. Although if
you're looping through a huge amount of files, it may be a bit slow. I recently used something
similar to this for getting all the jpg images in a specified directory.
<?php
$dir = opendir('path/to/directory');
if (!$dir)
return false;
while (($entry = readdir($dir)) !== false)
{
if (!preg_match('/^\./', $entry))
echo $entry;
}
closedir($dir);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 71.217.16.225
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- https://master.php.net/note/edit/107224
Del: integrated -- https://master.php.net/note/delete/107224/integrated
Del: useless -- https://master.php.net/note/delete/107224/useless
Del: bad code -- https://master.php.net/note/delete/107224/bad+code
Del: spam -- https://master.php.net/note/delete/107224/spam
Del: non-english -- https://master.php.net/note/delete/107224/non-english
Del: in docs -- https://master.php.net/note/delete/107224/in+docs
Del: other reasons-- https://master.php.net/note/delete/107224
Reject -- https://master.php.net/note/reject/107224
Search -- https://master.php.net/manage/user-notes.php