# Removing folders with files (PHP)

**URL:** <https://forum.kirupa.com/t/removing-folders-with-files-php/25848>\
**Category:** programming\
**Created:** [July 16, 2003, 11:49pm UTC](https://forum.kirupa.com/t/removing-folders-with-files-php/25848 "2003-07-16T23:49:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danneman](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@Danneman](https://forum.kirupa.com/u/Danneman)\
**Post date:** [July 16, 2003, 11:49pm UTC](https://forum.kirupa.com/t/removing-folders-with-files-php/25848/1 "2003-07-16T23:49:30Z")

</div>

I used…

rmdir($FOLDER);

…to remove a folder from the server.

However, it will only work when the folder is empty (ie. no files in it). And it doesnt matter if all the files have 777-permission (read-write-execute for all).

Is there a command that will delete the folder and all its content without having to go trough an exhausting “search-all-the-files-in-the-folder-and-delete-them” algortihm?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 16, 2003, 11:56pm UTC](https://forum.kirupa.com/t/removing-folders-with-files-php/25848/2 "2003-07-16T23:56:52Z")

</div>

[http://us3.php.net/manual/en/function.rmdir.php](http://us3.php.net/manual/en/function.rmdir.php)

more reading on rmdir

and read the posts at the bottom. They will show you codes that will delete the entire directory (empty or not)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 7:28pm UTC](https://forum.kirupa.com/t/removing-folders-with-files-php/25848/3 "2003-07-17T19:28:03Z")

</div>

Thanks Jubba, that page with all the functions will come in handy.
