filesize-in-units-indelen
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
function unitize($bin, $units, $lastUnit=0) {
if (($bin / 1024) > 1) {
$lastUnit++;
unitize($bin / 1024, $units, $lastUnit);
} else {
echo round($bin, 2) . ' ' . $units[$lastUnit];
}
}
function getFileSize($bin) {
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
unitize($bin, $units);
}
getFileSize(1000000000000000000000000/* quadriljoen bytes */);
?>
function unitize($bin, $units, $lastUnit=0) {
if (($bin / 1024) > 1) {
$lastUnit++;
unitize($bin / 1024, $units, $lastUnit);
} else {
echo round($bin, 2) . ' ' . $units[$lastUnit];
}
}
function getFileSize($bin) {
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
unitize($bin, $units);
}
getFileSize(1000000000000000000000000/* quadriljoen bytes */);
?>