<?php
/**
*
* @get size of a directory in bytes
*
* @param string $directory
*
* @return int
*
*/
function directorySize($directory)
{
$size = 0;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file)
{
$size += $file->getSize();
}
return $size;
}
/*** example implementation ***/
$directory = '/home/foo';
$size = directorySize($directory);
echo $size;
?>