From f064339b8bf3f89d12df87a736c47f18f507a7c4 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 19 Feb 2020 16:51:39 -0700 Subject: [PATCH] Update functions.php --- resources/functions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/functions.php b/resources/functions.php index d5b37d4f5b..25049e2bf0 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2091,4 +2091,18 @@ function number_pad($number,$n) { } } +//convert bytes to readable human format + if (!function_exists('byte_convert')) { + function byte_convert($bytes, $precision = 2) { + static $units = array('B','KB','MB','GB','TB','PB','EB','ZB','YB'); + $step = 1024; + $i = 0; + while (($bytes / $step) > 0.9) { + $bytes = $bytes / $step; + $i++; + } + return round($bytes, $precision).' '.$units[$i]; + } + } + ?>