Glob - Count the files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ozzy
Forum Commoner
Posts: 74
Joined: Tue Apr 11, 2006 4:45 pm

Glob - Count the files

Post by ozzy »

Hey, i think im in love with glob, it works with so many things. But i ahve a question, how would i count the files which have been displayed through glob.

I tryed

Code: Select all

$numberoffiles = count(glob("$files"));
or

Code: Select all

$numberoffiles = count(glob("$path"));
But it didnt seem to work, and the output is 1111111111 or 0000000000. Does anyone know why or where im going wrong?

Thanks in advance! :)

LOVE YOU <3
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That would depend on what $path and $files are. You have the correct syntax, if they are set correctly.
User avatar
ozzy
Forum Commoner
Posts: 74
Joined: Tue Apr 11, 2006 4:45 pm

Post by ozzy »

My current $files is:

Code: Select all

$files = glob($dir . 'vuns/files/*');
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

just count($files) would work then.
User avatar
ozzy
Forum Commoner
Posts: 74
Joined: Tue Apr 11, 2006 4:45 pm

Post by ozzy »

But then it returns as just the number '0', dispite me having over 100 files.
Post Reply