Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save volandku/a78a5ac4908dc1b903475122033202f3 to your computer and use it in GitHub Desktop.
Save volandku/a78a5ac4908dc1b903475122033202f3 to your computer and use it in GitHub Desktop.
Delete all subfolder and files
<?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);
}
}
?>
@volandku
Copy link
Author

volandku commented May 6, 2019

Быстро удалить весь сайт, когда только фтп есть

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment