Skip to content

Instantly share code, notes, and snippets.

@michaelaguiar
Created May 22, 2017 18:50
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Convert memory_get_usage() to a more readable number
<?php
public function convert($size)
{
$unit = ['b','kb','mb','gb','tb','pb'];
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment