Re: Changing Bytes to KB, to megs, to gigs.
| From: | Matthew A. Blasinski | Date: | Sat, 26 Jul 2003 22:08:36 +0000 |
| Subject: | Re: Changing Bytes to KB, to megs, to gigs. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157035@lists.php.net to get a copy of this message | ||
Philip J. Newman wrote:
My goal is to input the amount of Bytes used by a user as $inputbox and calculate how many kbs,megs,gigs along with $cost for the price per meg. <snip>
Questions? 1. Should I be dividing by 1024 or 1000? This was passed to me by word of mouth ... 2. Any way of rounding to 2 or 3 digests after the decimal point. 3. to remove any , from the inputted string.1) 1024 is more correct, so, use it unless what you're given was (incorrectly) calculated with 1000. 2) round($number, 2) - http://us4.php.net/manual/en/function.round.php 3) Use a search and replace (regular expression) to replace commas with empty strings. ereg_replace("," "", $string) - http://us4.php.net/manual/en/function.ereg-replace.php HTH, -- Matt Blasinski (mbv) Internet Infrastructure Applications Technology Division of Information Technology 3121 Computer Science and Statistics 1210 West Dayton Street Madison WI 53706 Work (608) 262-2286 Cell (608) 206-4098