note 83192 deleted from function.scandir by felipe
| From: | felipe@php.net | Date: | Fri, 29 Aug 2008 23:28:38 +0000 |
| Subject: | note 83192 deleted from function.scandir by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144011@lists.php.net to get a copy of this message | ||
Note Submitter: russell at russellfinlay dot com
----
A little snippet of code that will remove any files beginning with '.'
Good for removing '.' and '..' as well as any other hidden files.
Resulting array is $files
<?php
$dir = '.';
$files = scandir($dir);
foreach($files as $i => $value) {
if (substr($value, 0, 1) == '.') {
unset($files[$i]);
}
}
?>