Welcome to the Cookbook

loading...

7.6.4 toReadableSize

There is no translation yet for this section. Please help out and translate this.. More information about translations

toReadableSize(string $data_size)

This method formats data sizes in human readable forms. It provides a shortcut way to convert bytes to KB, MB, GB, and TB. The size is displayed with a two-digit precision level, according to the size of data supplied (i.e. higher sizes are expressed in larger terms):

echo $number->toReadableSize(0);  // 0 Bytes
echo $number->toReadableSize(1024); // 1 KB
echo $number->toReadableSize(1321205.76); // 1.26 MB
echo $number->toReadableSize(5368709120); // 5.00 GB
  1. echo $number->toReadableSize(0); // 0 Bytes
  2. echo $number->toReadableSize(1024); // 1 KB
  3. echo $number->toReadableSize(1321205.76); // 1.26 MB
  4. echo $number->toReadableSize(5368709120); // 5.00 GB