Skip to content

Instantly share code, notes, and snippets.

@mehdichaouch
Last active April 11, 2024 15:55
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save mehdichaouch/341a151dd5f469002a021c9396aa2615 to your computer and use it in GitHub Desktop.
Save mehdichaouch/341a151dd5f469002a021c9396aa2615 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());
@Germanir
Copy link

Germanir commented Jan 4, 2022

Great!
Thanks!

@StefanoTesla
Copy link

great utility!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment