note 127559 added to function.rmdir

From: Date: Wed, 31 Aug 2022 12:23:20 +0000
Subject: note 127559 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-219500@lists.php.net to get a copy of this message
a simple snipped for removing empty dirs recursive : <?php function removeEmptyDirs($fullPath) { if(!is_dir($fullPath)){ return; } $children = array_diff(scandir($fullPath), ['.','..']); foreach($children as $child){ removeEmptyDirs($fullPath. $child. DIRECTORY_SEPARATOR); } $children = array_diff(scandir($fullPath), ['.','..']); if(empty($children)){ echo "the $fullPath empty directory has been removed.\n"; rmdir($fullPath); } } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.173 (proxied: 132.148.72.22) ---- Manual Page -- https://php.net/manual/en/function.rmdir.php Edit -- https://main.php.net/note/edit/127559 Del: integrated -- https://main.php.net/note/delete/127559/integrated Del: useless -- https://main.php.net/note/delete/127559/useless Del: bad code -- https://main.php.net/note/delete/127559/bad+code Del: spam -- https://main.php.net/note/delete/127559/spam Del: non-english -- https://main.php.net/note/delete/127559/non-english Del: in docs -- https://main.php.net/note/delete/127559/in+docs Del: other reasons-- https://main.php.net/note/delete/127559 Reject -- https://main.php.net/note/reject/127559 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219500) next »