Se al posto di una qualsiasi directory (in questa caso webcam) non metto niente, ovviamente perche le cartelle che voglio eliminare si trovano in quella principale (/), non funziona
Codice PHP:
<?php 
/** 
 * Delete a file, or a folder and its contents (recursive algorithm) 
 * 
 * @author      Aidan Lister <aidan@php.net> 
 * @version     1.0.3 
 * @link        [url="http://aidanlister.com/repos/v/function.rmdirr.php"][url]http://aidanlister.com/repos/v/function.rmdirr.php[/url][/url] 
 * @param       string   $dirname    Directory to delete 
 * @return      bool     Returns TRUE on success, FALSE on failure 
 */ 
function rmdirr($dirname

    
// Sanity check 
    
if (!file_exists($dirname)) { 
        return 
false
    } 

    
// Simple delete for a file 
    
if (is_file($dirname) || is_link($dirname)) { 
        return 
unlink($dirname); 
    } 

    
// Loop through the folder 
    
$dir dir($dirname); 
    while (
false !== $entry $dir->read()) { 
        
// Skip pointers 
        
if ($entry == '.' || $entry == '..') { 
            continue; 
        } 

        
// Recurse 
        
rmdirr($dirname DIRECTORY_SEPARATOR $entry); 
    } 

    
// Clean up 
    
$dir->close(); 
    return 
rmdir($dirname); 

  



  
$curr date("Ymd"time());  
  
$base_path "webcam";  
  
$handle opendir($base_path);  
   
  if (
$handle) { 
      while (
false !== ($file readdir($handle))) { 
          if (
$file != "." && $file != ".." && $file != $curr && is_dir($base_path."/".$file)) { 
              
rmdirr($base_path."/".$file);               
          }           
      } 
      
closedir($handle); 
  } 
?>