Les Snippets

Connexion

Convertir un nombre en taille (Ko,Mo,Go)

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 25/03/2006 23:35:22 et initié par EBArtSoft [Liste]
Date de mise à jour : 05/08/2006 14:25:59
Vue : 15550
Catégorie(s) : Fichier / Disque, Trucs & Astuces, Chaîne de caractères
Langages dispo pour ce code :
- VB6, VBA
- Delphi 5
- PHP 3, PHP 4, PHP 5
- PHP 3, PHP 4, PHP 5
- Perl
- Voir tous les langages pour ce code snippet



Langage : PHP 3 , PHP 4 , PHP 5
Date ajout : 04/06/2007
Posté par coucou747 [Liste]
function int2taille($i, $b=1024){
    $o=$i%1024;
    $k=(int)(($i/$b)%$b);
    $m=(int)(($i/$b/$b)%$b);
    $g=(int)(($i/$b/$b/$b));
    return (($g!=0)?($g.' Go '.$m.' Mo '.$k.' Ko '.$o.' o'):($m!=0)?($m.' Mo '.$k.' Ko '.$o.' o'):(($k!=0)?$k.' Ko '.$o.' o':$o.' o'));
}