Skip to content

Instantly share code, notes, and snippets.

@kazumich
Last active March 4, 2022 08:43
Show Gist options
  • Save kazumich/c12d1ecf87acfe1b6e5f to your computer and use it in GitHub Desktop.
Save kazumich/c12d1ecf87acfe1b6e5f to your computer and use it in GitHub Desktop.
掃除用
<?php
// --------------------------
//
// 掃除用
//
// --------------------------
$deletePath = realpath('.');
rrmdir($deletePath,$deletePath);
echo $deletePath. " delete !";
// --------------------------
// ディレクトリを削除する function
// --------------------------
function rrmdir($dir,$start) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object,$start); else unlink($dir."/".$object);
}
}
reset($objects);
if ($start != $dir) rmdir($dir);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment