note 95913 modified in function.scandir by danbrown

From: Date: Thu, 28 Jan 2010 14:11:42 +0000
Subject: note 95913 modified in function.scandir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165437@lists.php.net to get a copy of this message
This is a function to count the number of files of a directory <?php function countFiles($dir){ $files = array(); $directory = opendir($dir); while($item = readdir($directory)){ // We filter the elements that we don't want to appear ".", ".." and ".svn" if(($item != ".") && ($item != "..") && ($item != ".svn") ){ $files[] = $item; } } $numFiles = count($files); return $numFiles; } ?> --was-- This is a function to count the number of files of a directory function countFiles($dir){ $files = array(); $directory = opendir($dir); while($item = readdir($directory)){ // We filter the elements that we don't want to appear ".", ".." and ".svn" if(($item != ".") && ($item != "..") && ($item != ".svn") ){ $files[] = $item; } } $numFiles = count($files); return $numFiles; } http://php.net/manual/en/function.scandir.php

« previous php.notes (#165437) next »