Answers for "php delete folder and contents"

PHP
0

php delete a folder

function deleteDirectory($dir) {
    if (!file_exists($dir)) {
        return true;
    }

    if (!is_dir($dir)) {
        return unlink($dir);
    }

    foreach (scandir($dir) as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }

        if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
            return false;
        }

    }

    return rmdir($dir);
}
Posted by: Guest on March-10-2021
2

php delete directory

rmdir ( string $dirname , resource $context = ? ) : bool
Posted by: Guest on January-12-2021

Code answers related to "php delete folder and contents"

Browse Popular Code Answers by Language