Skip to content

Instantly share code, notes, and snippets.

@lnfel
Forked from mehdichaouch/memory_usage.php
Created October 14, 2021 05:27
Show Gist options
  • Save lnfel/73e6ef793b690b2905216e3b8742fe3d to your computer and use it in GitHub Desktop.
Save lnfel/73e6ef793b690b2905216e3b8742fe3d to your computer and use it in GitHub Desktop.
PHP Snippet to get human readable memory usage
<?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