Created
May 6, 2019 23:43
-
-
Save volandku/a78a5ac4908dc1b903475122033202f3 to your computer and use it in GitHub Desktop.
Delete all subfolder and files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = glob(dirname(__FILE__).'/*', GLOB_BRACE); | |
// var_dump($files); | |
function Delete($path) | |
{ | |
if (is_dir($path) === true) | |
{ | |
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST); | |
foreach ($files as $file) | |
{ | |
if (in_array($file->getBasename(), array('.', '..')) !== true) | |
{ | |
if ($file->isDir() === true) | |
{ | |
rmdir($file->getPathName()); | |
} | |
else if (($file->isFile() === true) || ($file->isLink() === true)) | |
{ | |
unlink($file->getPathname()); | |
} | |
} | |
} | |
return rmdir($path); | |
} | |
else if ((is_file($path) === true) || (is_link($path) === true)) | |
{ | |
return unlink($path); | |
} | |
return false; | |
} | |
foreach ($files as $file) | |
{ | |
if (is_dir($file)) | |
{ | |
echo $file; | |
Delete($file); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Быстро удалить весь сайт, когда только фтп есть