View Single Post
  #2 (permalink)  
Old 05-03-05, 05:10 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
yes it's possible to count files in a directory..
simply use scandir() function like this:
PHP Code:

$files = @scandir('mydir');


if (
$files)
   
$num_of_files count($files) - 2// we substract 2 because . and .. are included
else
   die(
'there is an error');

if (isset(
$num_of_files) && !empty($num_of_files))
    echo 
"There are $num_of_files files in the directory";
else
    echo 
'no files found!'
this will count the number of files found in the directory "mydir" and then assign the names to the array $files.
you can manipulate this array with foreach() like:
PHP Code:

$link null;


foreach(
$files as $file)
    
$link .= "column{$file}.html\n";

echo 
$link
this will print the files found like:
columnFILENAME.html

HTH
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 05-03-05 at 05:13 PM.
Reply With Quote