Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Print file size in Ko, Mo, Go, To, Po,...
SUBMITTED BY:
Guest
DATE:
March 27, 2015, 1:15 p.m.
FORMAT:
PHP
SIZE:
418 Bytes
Raw
Download
Tweet
HITS:
1106
Go to comments
Report
function taille_fichier($octets) {
$resultat = $octets;
for ($i=0; $i < 8 && $resultat >= 1024; $i++) {
$resultat = $resultat / 1024;
}
if ($i > 0) {
return preg_replace('/,00$/', '', number_format($resultat, 2, ',', '')) . ' ' . substr('KMGTPEZY',$i-1,1) . 'o';
} else {
return $resultat . ' o';
}
}
echo taille_fichier(1024); // affiche : 1 Ko
?>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus