$t) { //if the file is older than one week, delete recursiveDelete($a_dir.'/'.$item); } } /** * Delete a file or recursively delete a directory * * @param string $str Path to file or directory */ function recursiveDelete($str){ if(is_file($str)){ return @unlink($str); } elseif(is_dir($str)){ $scan = glob(rtrim($str,'/').'/*'); foreach($scan as $index=>$path){ recursiveDelete($path); } return @rmdir($str); } }