General Community > Scripting Help
script to count files with an extension
Metho:
Use that instead of my ereg_replace, please. Thanks, [Unknown]. :D
Methonis
chris:
Take a look at: http://de.php.net/manual/en/function.pathinfo.php and http://de.php.net/manual/en/function.basename.php
untested:
--- Code: ---<?php
$files = array();
$dir = @opendir('/usr/home/web/users/a0013745/html/RodSerling/Chat/poets');
while (($file = readdir($dir)) !== false)
{
$parts = pathinfo($file);
if ($path_parts['extension'] == '.who')
{
$files[] = basename($parts['basename'],'.who');
}
}
closedir($dir);
sort($files);
// Output results
echo count($files).' files match<br />';
foreach($files AS $name)
{
echo $name;
}
?>
--- End code ---
;D
Navigation
[0] Message Index
[*] Previous page
Go to full version