-
-
Save peterujah/34b876e5a407947580278fff0cbc54fd to your computer and use it in GitHub Desktop.
PHP function to get the folder size including subfolders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function folderSize ($dir) | |
| { | |
| $size = 0; | |
| foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) { | |
| $size += is_file($each) ? filesize($each) : folderSize($each); | |
| } | |
| return $size; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment