|
Posted by Fred Atkinson on 01/14/08 04:40
On Sun, 13 Jan 2008 20:59:03 -0500, Fred Atkinson
<fatkinson@mishmash.com> wrote:
OK,
I think I've got it.
I slightly rewrote your script (one line with an if statement)
to include a second comparison.
Here it is:
<?php
$dir = './directory';
function countfiles($dir = '.')
{
$count = 0;
$dir = rtrim($dir,'/').'/';
if(!is_dir($dir)) return false;
foreach(new DirectoryIterator($dir) as $file)
{
if((is_file($dir.$file) && preg_match("/.jpg\z/i",
$file))) $count++;
}
return $count;
}
echo countfiles();
echo " file(s) in this directory."
?>
It seems to work just fine. It ignores anything except .jpg
files.
Regards,
Fred
[Back to original message]
|