note 109681 added to function.readdir
| From: | bsienn dot khan at gmail dot com dot com | Date: | Thu, 09 Aug 2012 07:03:36 +0000 |
| Subject: | note 109681 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189968@lists.php.net to get a copy of this message | ||
**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);
}
----
Server IP: 69.147.83.197
Probable Submitter: 182.187.2.112
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- https://master.php.net/note/edit/109681
Del: integrated -- https://master.php.net/note/delete/109681/integrated
Del: useless -- https://master.php.net/note/delete/109681/useless
Del: bad code -- https://master.php.net/note/delete/109681/bad+code
Del: spam -- https://master.php.net/note/delete/109681/spam
Del: non-english -- https://master.php.net/note/delete/109681/non-english
Del: in docs -- https://master.php.net/note/delete/109681/in+docs
Del: other reasons-- https://master.php.net/note/delete/109681
Reject -- https://master.php.net/note/reject/109681
Search -- https://master.php.net/manage/user-notes.php