note 29392 added to function.is-file
| From: | rlh at d8acom dot com | Date: | Wed, 12 Feb 2003 11:17:34 +0000 |
| Subject: | note 29392 added to function.is-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43817@lists.php.net to get a copy of this message | ||
I do a lot of file parsing and have found the following technique extremely useful:
while (false !== ($document = readdir($my_dir)))
{
$ext=explode('.',$document);
if($document != '.' && $document != '..' && $ext[1])
{
'Do something to file...'
}
}
It gets around the fact that, when working on website pages, the html files are read as directories
when downloaded. It also allows you to extend the usefulness of the above method by adding the
ability to determine file types e.g.
if($document != '.' && $document != '..' &&
$ext[1]=='htm')
or
if($document != '.' && $document != '..' &&
$ext[1]=='doc')
--
http://www.php.net/manual/en/function.is-file.php
http://master.php.net/manage/user-notes.php?action=edit+29392
http://master.php.net/manage/user-notes.php?action=delete+29392
http://master.php.net/manage/user-notes.php?action=reject+29392