delite - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of delite.php

  1. <?php
  2.  
  3. function removeEmptyFolders($path)
  4. {
  5.     $isFolderEmpty = true; 
  6.  
  7.     if(substr($path, -1) == "/") 
  8.         $pathForGlob = $path . "*"; 
  9.     else
  10.         $pathForGlob = $path . DIRECTORY_SEPARATOR . "*"; 
  11.  
  12.     
  13.     foreach (glob($pathForGlob) as $file)
  14.     {
  15.         if (is_dir($file))
  16.         {
  17.             
  18.             if (!removeEmptyFolders($file))
  19.                 $isFolderEmpty = false;
  20.         }
  21.         else 
  22.         {
  23.             
  24.             $isFolderEmpty = false;
  25.         }
  26.     }
  27.  
  28.  
  29.     if ($isFolderEmpty)
  30.         rmdir($path);
  31.  
  32.     
  33.     return $isFolderEmpty;
  34. }
  35.  
  36. removeEmptyFolders("C:\Users\grzda\OneDrive\Dekstop\test");
  37.  
  38.  
  39. ?>
File Description
  • delite
  • PHP Code
  • 25 Nov-2022
  • 651 Bytes
You can Share it: