Pesquisar por:
rmdir — Remove um diretório no PHP
<?php

function deleteDirectory($dirname,$only_empty=false) {
   if (!is_dir($dirname))
       return false;
   $dscan = array(realpath($dirname));
   $darr = array();
   while (!empty($dscan)) {
       $dcur = array_pop($dscan);
       $darr[] = $dcur;
       if ($d=opendir($dcur)) {
           while ($f=readdir($d)) {
               if ($f=='.' || $f=='..')
                   continue;
               $f=$dcur.'/'.$f;
               if (is_dir($f))
                   $dscan[] = $f;
               else
                   unlink($f);
           }
           closedir($d);
       }
   }
   $i_until = ($only_empty)? 1 : 0;
   for ($i=count($darr)-1; $i>=$i_until; $i--) {
       echo "\nDeleting '".$darr[$i]."' ... ";
       if (rmdir($darr[$i]))
           echo "ok";
       else
           echo "FAIL";
   }
   return (($only_empty)? (count(scandir)<=2) : (!is_dir($dirname)));
}

 Consulte mais informação
Tamanho de Diretório, número de arquivos e sub-diretórios no PHP

<?php

function getDirectorySize($path) {

 $totalsize = 0;
 $totalcount = 0;
 $dircount = 0;
 if ($handle = opendir ($path))
 {
   while (false !== ($file = readdir($handle)))
   {
     $nextpath = $path . '/' . $file;
     if ($file != '.' && $file != '..' && !is_link ($nextpath))
     {
       if (is_dir ($nextpath))
       {
         $dircount++;
         $result = getDirectorySize($nextpath);
         $totalsize += $result['size'];
         $totalcount += $result['count'];
         $dircount += $result['dircount'];
       }
       elseif (is_file ($nextpath))
       {
         $totalsize += filesize ($nextpath);
         $totalcount++;
       }
     }
   }
 }
 closedir ($handle);
 $total['size'] = $totalsize;
 $total['count'] = $totalcount;
 $total['dircount'] = $dircount;
 return $total;

Consulte mais informação