Skip to content

Instantly share code, notes, and snippets.

@zaynali53
Last active August 1, 2016 06:08
Show Gist options
  • Select an option

  • Save zaynali53/bcf2bcb289aa1b0c6efd to your computer and use it in GitHub Desktop.

Select an option

Save zaynali53/bcf2bcb289aa1b0c6efd to your computer and use it in GitHub Desktop.
Recursively deletes files within folders
<?php
function removeFiles($path)
{
if (is_dir($path)) {
$files = glob($path . '*', GLOB_MARK);
foreach ($files as $file) {
removeFiles($file);
}
rmdir($path);
} elseif (is_file($path)) {
unlink($path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment