Category: PHP, PHP

There are lot of useful inbuilt functions that comes with PHP interpreter. One such function is rmdir which allows us to delete a folder/directory through PHP code.

As useful this function is, it fails to delete a directory when the directory is not empty throwing a warning message Directory not empty. As a workaround, we need to first delete all files and folders recursively inside the specified directory and then delete the directory itself.

Here, we are passing RecursiveIteratorIterator::CHILD_FIRST as mode to get the children of the directory before getting the directory name itself.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners