Skip to content

Instantly share code, notes, and snippets.

@richjenks
Created February 19, 2017 15:30
Show Gist options
  • Save richjenks/2ce4593fcbe62727052ca41f241ff9d6 to your computer and use it in GitHub Desktop.
Save richjenks/2ce4593fcbe62727052ca41f241ff9d6 to your computer and use it in GitHub Desktop.
<?php
function delete($path) {
$files = scandir($path);
foreach ($files as $file) {
if (!in_array($file, ['.', '..'])) {
$full = $path . DIRECTORY_SEPARATOR . $file;
if (is_file($full)) unlink($full);
if (is_dir($full)) delete($full);
}
}
rmdir($path);
}
// delete(__DIR__ . '/folder');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment