Solution #1
<?php
$dirs = (array) $dir;
while (list(,$v) = each($dirs)) {
    if (!($d = opendir($v))) {
        exit("We demand access!\n");
    }
        while (($f = readdir($d))) {
        if ($f == '.' || $f == '..') {
            continue;
        }
                if (is_file($v . "/" . $f)) {
                    echo "Found {$f} file inside {$v} directory\n";
                } else {
                    echo "Found a new directrory {$v}/{$f}\n";
            $dirs[] = $v . "/" . $f;
        }
    }
    closedir($d);
}
?>



Solution #2
<?php
$a = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($dir) );
foreach ($a as $v) {
    echo "Size of: ".$v->getPath()."/".(string) $v . " is ".
    $v->getSize()." bytes\n";
}
?>
                                  



<?php
funciton concat() 
{
    return implode('', get_func_args());
}

sqlite_create_function($db, 'CONCAT', 'CONCAT');
?>