|
Posted by Daniel Ennis on 01/14/08 06:43
Fred Atkinson wrote:
> 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
GJ :) Hope what ever your working on comes out well!
And yes, the default PHP5 functions will be faster than old style code,
as its optimized C++ doing all the tasks you would normally do manually
in PHP4.
--
Daniel Ennis
faNetworks.net - Quality Web Hosting and Ventrilo Services
System Administrator / Web Developer
PHP Developer for 6 years
daniel@fanetworks.net
[Back to original message]
|