Last active
July 28, 2024 00:49
-
-
Save mehdichaouch/341a151dd5f469002a021c9396aa2615 to your computer and use it in GitHub Desktop.
PHP Snippet to get human readable memory usage
This file contains 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 convert($size) | |
{ | |
$unit=array('b','kb','mb','gb','tb','pb'); | |
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; | |
} | |
convert(memory_get_usage()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great utility!