Thanks mate. I made it work like this:
<?
$all;
$typer = array( "php", "pdf", "htm", "zip", "jpg", "avi" ); //delete or add types here.
foreach( $typer as $type ) {
$bytes=0;
$filer=0;
tree( "./", $type, 3, "" ); //or replace "./" with a specific path.
$all += $mb;
$kb = $bytes/1024;
$mb=$kb/1024;
$gb=$mb/1024;
$size[$type] = $mb;
$files[$type] = $filer;
}
$filestotal=0;
$bytestotal=0;
foreach( $size as $type => $mb) {
echo "<b>$files[$type]</b>" . " " . "." .$type . "-files " . " " . "with a total size of " . " " . number_format($mb, 2, ',', '.') . " " . "mb." . "<br />";
$filestotal += $files[$type];
$bytestotal += $bytes;
}
{
echo "<strong>" . " " . number_format($all += $mb, 2, ',', '.') . " " . "mb.</strong>";
}
function tree( $path, $type ) {
global $bytes, $filer;
$d = dir($path);
while (false !== ($entry = $d->read())) {
$etdir = is_dir($path.$entry);
if( $entry != "." && $entry != ".." && $entry != "" ) {
$path_parts = pathinfo($entry);
if( strstr($type, $path_parts["extension"]) || $type=="*" && !$etdir ) {
$bytes += filesize($path.$entry);
$filer++;
}
if( $etdir ) {
tree( $path.$entry."/", $type);
}
}
}
$d->close();
}
?>