note 72969 added to function.number-format

From: Date: Tue, 06 Feb 2007 10:27:57 +0000
Subject: note 72969 added to function.number-format
Groups: php.notes 
Request: Send a blank email to php-notes+get-122911@lists.php.net to get a copy of this message
simpler function to convert a number in bytes, kilobytes.... <?php function bytes($a) { $unim = array("B","KB","MB","GB","TB","PB"); $c = 0; while ($a>=1024) { $c++; $a = $a/1024; } return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c]; } ?> you may also add others units over PeraBytes when the hard disks will reach 1024 PB :) ---- Server IP: 80.241.173.254 Probable Submitter: 82.91.105.68 ---- Manual Page -- http://www.php.net/manual/en/function.number-format.php Edit -- https://master.php.net/note/edit/72969 Del: integrated -- https://master.php.net/note/delete/72969/integrated Del: useless -- https://master.php.net/note/delete/72969/useless Del: bad code -- https://master.php.net/note/delete/72969/bad+code Del: spam -- https://master.php.net/note/delete/72969/spam Del: non-english -- https://master.php.net/note/delete/72969/non-english Del: in docs -- https://master.php.net/note/delete/72969/in+docs Del: other reasons-- https://master.php.net/note/delete/72969 Reject -- https://master.php.net/note/reject/72969 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122911) next »