If you want to delete everything from folder (including subfolders) use this combination of array_map
, unlink
and glob
:
array_map( 'unlink', array_filter((array) glob("path/to/temp/*") ) );
This call can also handle empty directories ( thanks for the tip, @mojuba!)