<?php /* function isEmptyDir($dir) { return (($files = @scandir($dir)) && count($files) <= 2); } echo "plouf"; $r = isEmptyDir("Utilisateurs/zorro"); echo $r; function checkFolderIsEmptyOrNot ( $folderName ){ $files = array (); if ( $handle = opendir ( $folderName ) ) { while ( false !== ( $file = readdir ( $handle ) ) ) { if ( $file != "." && $file != ".." ) { $files [] = $file; } } closedir ( $handle ); } //return ( count ( $files ) > 0 ) ? TRUE: FALSE; return ( count ( $files ) ); } echo checkFolderIsEmptyOrNot ("Utilisateurs/zorro"); */ function efface_repertoire($path) { $files = glob($path . '/*'); foreach ($files as $file) { is_dir($file) ? efface_repertoire($file) : unlink($file); } rmdir($path); //return; } efface_repertoire("Utilisateurs/zorro/patoche") ?>