Reply to Re: Command

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация