Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Format a number with grouped thousands
<?php number_format( float $num, int $decimals = 0, ?string $decimal_separator = ".", ?string $thousands_separator = ","): string
<?php protected function sizeKilobytes()
{
return (float) number_format($this->sizeBytes() / 1024, 2);
}
protected function sizeKb()
<?php protected function sizeMegabytes()
{
return (float) number_format($this->sizeBytes() / 1048576, 2);
}
protected function sizeMb()
<?php protected function sizeGigabytes()
{
return (float) number_format($this->sizeBytes() / 1073741824, 2);
}
protected function sizeGb()
<?php return $submission->get($field);
});
return number_format($value, $this->get('precision', 2));
}
}
<?php $number = floatval(str_replace(',', '', $value));
return number_format($number, $precision, $dec_point, $thousands_sep);
}
<?php $pathinfo = pathinfo($path);
$size = File::size($path);
$kb = number_format($size / 1024, 2);
$mb = number_format($size / 1048576, 2);
$gb = number_format($size / 1073741824, 2);
<?php $size = File::size($path);
$kb = number_format($size / 1024, 2);
$mb = number_format($size / 1048576, 2);
$gb = number_format($size / 1073741824, 2);
$data[] = [
<?php $size = File::size($path);
$kb = number_format($size / 1024, 2);
$mb = number_format($size / 1048576, 2);
$gb = number_format($size / 1073741824, 2);
$data[] = [
'file' => URL::format($path), // Todo: This will only work when using the local file adapter
<?php public static function fileSizeForHumans($bytes, $decimals = 2)
{
if ($bytes >= 1073741824) {
$bytes = number_format($bytes / 1073741824, $decimals).' GB';
} elseif ($bytes >= 1048576) {
$bytes = number_format($bytes / 1048576, $decimals).' MB';
} elseif ($bytes >= 1024) {
<?php if ($bytes >= 1073741824) {
$bytes = number_format($bytes / 1073741824, $decimals).' GB';
} elseif ($bytes >= 1048576) {
$bytes = number_format($bytes / 1048576, $decimals).' MB';
} elseif ($bytes >= 1024) {
$bytes = number_format($bytes / 1024, $decimals).' KB';
} elseif ($bytes > 1) {
<?php } elseif ($bytes >= 1048576) {
$bytes = number_format($bytes / 1048576, $decimals).' MB';
} elseif ($bytes >= 1024) {
$bytes = number_format($bytes / 1024, $decimals).' KB';
} elseif ($bytes > 1) {
$bytes = $bytes.' B';
} elseif ($bytes == 1) {