counting files in directories
Moderator: General Moderators
counting files in directories
I know I can just read all the files in the directory with readdir() but is there a more effective way to do this if i just wish to know how many files are inside of a directory?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
my favorite, but slightly complicated for some
Code: Select all
$num = count(array_filter(glob('/some/path/*'),'is_file')));not sure about effectiveness but i like this way:
Code: Select all
$num = shell_exec("ls /path/to/dir|wc -l");- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US