Can anyone tell me how I can show a variable with a unit. This is what im trying to get:
515Mbs
But if i use this then it treats the entire string as a variable and I dont want to leave a space between $number and Mbs.
$numberMbs
Stuart
$number = 515; echo $number . 'Mbs'; // outputs 515Mbs
$size = 123456789; // in bytes $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size > 1024; $i++) { $size /= 1024; } echo rtrim(number_format($size, 2, '.', ','), '.0').$units[$i];
Outputs: 117.74 MB
:p