After thinking mine was in error,
I found LOT AT LOTS of scripts the do this: https://gist.github.com/liunian/9338301
And there are several here at S.O. I used, but had the same annoying "B" as a size.
This issue seemed to rear it's ugly head when I switched to php v7.xxx First issues is I have to typcase a floated number (or double) or else I get a "A non well formed numeric value encountered" After some research, apparently this is NOT a bug. At least that is how I read it.
So after typcasting it, the error goes away but the value returned is always a "B' filesize = 87.5B (when it should be MB or GB).
I am pretty sure Javascript will work, but would rather keep it with php.
Thanks for looking
current live script that is producing a "B" only
public function readableBytes($size, $type='pc') { //ignore the pc - it is for something else - disabled for debugging
$size = (double)$size;
static $units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$step = 1024;
$i = 0;
while (($size / $step) > 0.9) {
$size = $size / $step;
$i++;
}
return round($size, 2).$units[$i];
}// function readbbleBytes
(87.25 B) – Jake Stone Nov 22 '18 at 21:38