well i want to get the total size of a directory, ive managed to get this code to display the file size of every file in the directory
PHP Code:
<?php
$dir = "../demo/themes/";
$tree = array();
$dirs = array(array($dir, &$tree));
for($i = 0; $i < count($dirs); ++$i)
{
$d = opendir($dirs[$i][0]);
$tier =& $dirs[$i][1];
while($file = readdir($d))
{
if ($file != '.' and $file != '..')
{
$path = $dirs[$i][0] . DIRECTORY_SEPARATOR . $file;
if (is_dir($path))
{
$tier[$file] = array();
$dirs[] = array($path, &$tier[$file]);
}
else
{
$size2 = filesize($path);
$size = array($size2);
print_r($size);
echo "<br>";
}
}
}
}
/*
?>
the only problem is adding all them together. my inital idea was to create a array that stores the file size in a new element then just create a loop that adds them all together. the only problem i have is every file size is stored in array element 0
HTML Code:
Array ( [0] => 0 )
Array ( [0] => 881 )
Array ( [0] => 97 )
Array ( [0] => 970 )
Array ( [0] => 1246 )
Array ( [0] => 0 )
Array ( [0] => 123 )
Array ( [0] => 1678 )
Array ( [0] => 1661 )
Array ( [0] => 2184 )
Array ( [0] => 8689 )
All help is appreciated, thank you.