note 119322 deleted from function.rmdir by cmb

From: Date: Thu, 12 May 2016 17:30:58 +0000
Subject: note 119322 deleted from function.rmdir by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-205475@lists.php.net to get a copy of this message
Note Submitter: frederico05 dot figueira at gmail dot com ---- <?php //This is one example to delete full directory with all files inside there function delDir($path){ if(is_dir($path) == TRUE){ $rootFolder = scandir($path); if(sizeof($rootFolder) > 2){ foreach($rootFolder as $folder){ if($folder != "." && $folder != ".."){ //Pass the subfolder to function delDir($path."/".$folder); } } //On the end of foreach the directory will be cleaned, and you will can use rmdir, to remove it rmdir($path); } }else{ if(file_exists($path) == TRUE){ unlink($path); } } } ?>

« previous php.notes (#205475) next »