Skip to content

Instantly share code, notes, and snippets.

@mehdichaouch
Last active October 14, 2024 10:53
Show Gist options
  • 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());
@StefanoTesla
Copy link

great utility!

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