note 109681 deleted from function.readdir by danbrown
| From: | danbrown@php.net | Date: | Fri, 10 Aug 2012 16:07:35 +0000 |
| Subject: | note 109681 deleted from function.readdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189992@lists.php.net to get a copy of this message | ||
Note Submitter: bsienn dot khan at gmail dot com dot com
----
**For getting images only for specified extensions:**
$i = 0;
$picsArray = Array();
$allowedExts = array("jpg", "jpeg", "gif", "png");
//Read files from directory and saves the list in array
if ($handle = opendir('../images/'))
{
while (false !== ($entry = readdir($handle)))
{
if ($entry != "." && $entry != "..")
{
$extension = end(explode(".", $entry));
if (in_array($extension, $allowedExts))
$picsArray[$i++] = $entry;
}
}
closedir($handle);
}