Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php remove directory only if empty

<?php

    function removeEmptyDirs($path, $checkUpdated = false, $report = false) {
        $dirs = glob($path . "/*", GLOB_ONLYDIR);

        foreach($dirs as $dir) {
            $files = glob($dir . "/*");
            $innerDirs = glob($dir . "/*", GLOB_ONLYDIR);
            if(empty($files)) {
                if(!rmdir($dir))
                    echo "Err: " . $dir . "<br />";
               elseif($report)
                    echo $dir . " - removed!" . "<br />";
            } elseif(!empty($innerDirs)) {
                removeEmptyDirs($dir, $checkUpdated, $report);
                if($checkUpdated)
                    removeEmptyDirs($path, $checkUpdated, $report);
            }
        }

    }


?>
Comment

PREVIOUS NEXT
Code Example
Php :: Convert an Integer Into a String in PHP 
Php :: PHP if...else...elseif Statements 
Php :: Get class of an object variable php 
Php :: create crud controller in laravel 5.8 
Php :: laravel with select 
Php :: if one condition 
Php :: https://ubuntu.com/tutorials/install-and-configure-wordpress#3-install-wordpress 
Php :: where is cache file in laravel 
Php :: heredoc 
Php :: laravel run function after forgot password 
Php :: laravel login and registration with command 
Php :: check nulls in php 8 
Php :: image laravel 
Php :: cache for php website 
Php :: how to give points to referrer in laravel 
Php :: php javascript dynamic form 
Php :: add class to li 
Php :: ezSql PDO Connection 
Php :: menyimpan get di laravel 
Php :: php run server laravel 
Php :: php artisan tinker get records 
Php :: enable mcrypt in php ini in xampp php.ini 
Php :: 100 rows update php 
Php :: laravel 7 link to another page with language prefix 
Php :: how-to-customize-the-email-verification-email-from-laravel-8 
Php :: $n = readline(); for($i = 0; $i < $n ; $i++) { $name = readline(); $names[$name] = (isset($names[$name]) ? $names[$name] + 1 : 1); } 
Php :: Find template serving current page 
Php :: laravel how to read app/config/app.php debug variable 
Php :: change regards line laravel 
Php :: Laravel advanced sub queries 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =