Page 1 of 1

Count Files on Directory?

Posted: Sat Jun 26, 2010 6:05 pm
by gertrudis
Hi all.
I need to know how can i count files using the first 3 beginning letter of file name:

this is the code i'm using, it list and sort the files on the directory bu I need to count it:

for ($count=0;$count<count($filelist);$count++)
{
$filename=$filelist[$count];
if (!is_dir($filename))
$nombase=(basename($filename));
printf (substr("$nombase", 0, 2));
}
All files start with two number or letter example:
Files Total
10 35
13 55
15 25
16 29

Thank in advance

Re: Count Files on Directory?

Posted: Sat Jun 26, 2010 6:25 pm
by requinix
Here's something to start you off:

Code: Select all

$count = array();
Since that's not much I'll give you a bit more:

Code: Select all

if (!isset($count[$prefix])) $count[$prefix] = 1; else $count[$prefix]++;

Re: Count Files on Directory?

Posted: Mon Jun 28, 2010 11:31 am
by gertrudis
Thanks a lot :crazy: