Created
May 22, 2017 18:50
-
-
Save michaelaguiar/7be97a69a0ea40ab52de4876a97a8794 to your computer and use it in GitHub Desktop.
Convert memory_get_usage() to a more readable number
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 | |
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