PHP – Delete Directory and Content Recursively
Here is a simple php code that will delete the directory and its content recursively.
Example Code :
- <?php
- function rrmdir($dir){
- if (is_dir($dir)){
- $objects = scandir($dir);
- foreach ($objects as $object){
- if ($object != “.” && $object != “..”){
- if (filetype($dir.“/”.$object) == “dir”) rrmdir($dir.“/”.$object); else unlink($dir.“/”.$object);
- }
- }
- reset($objects);
- rmdir($dir);
- }
- }
- ?>
Follow @phpzag

I just couldn’t leave your web site prior to suggesting that I really enjoyed the standard info an individual supply in your guests? Is going to be again frequently to check up on new posts.
Nice read, I just passed this onto a colleague who was doing a little research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thanks for lunch! “Not only is the universe stranger than we imagine, it is stranger than we can imagine.” by Sir Arthur Eddington.
I’ll right away grasp your rss as I can’t find your email subscription hyperlink or e-newsletter service. Do you’ve any? Kindly permit me realize in order that I may just subscribe. Thanks.
Thanks, I’ve just been searching for info about this topic for ages and yours is the greatest I’ve discovered so far. However, what concerning the bottom line? Are you certain in regards to the supply?
I gotta favorite this site it seems very useful very beneficial
I’m very pleased to uncover this web site. I need to to thank you for ones time for this particularly fantastic read!! I definitely appreciated every part of it and i also have you bookmarked to look at new things in your site.
I consider something truly fascinating about your internet site so I saved to fav.
This really is a excellent weblog, would you be involved in performing an interview about just how you designed it? If so e-mail me!