Categories
Snaps
Search
Register
Contact
API
Convert bytes.
Converts an input of bytes into kilobytes and upwards.
<? function convert($b) { # Perform Calculation $kb = $b / 1024; $mb = $kb / 1024; $gb = $mb / 1024; $tb = $gb / 1024; $pb = $tb / 1024; # Round As Necessary if ($b > 1) {$s = round($b, 2) . "B";} if ($kb > 1) {$s = round($kb, 2) . "KB";} if ($mb > 1) {$s = round($mb, 2) . "MB";} if ($gb > 1) {$s = round($gb, 2) . "GB";} if ($tb > 1) {$s = round($tb, 2) . "GB";} if ($pb > 1) {$s = round($pb, 2) . "PB";} # Return Convert return $s; } ?>
Usage
print convert(34242342);
Comments
Add your comment
Search
Login
Coder: vivei
View more snaps from vivei
View vivei's profile
Rate this snap
Rating:
4
/ 5 (
1
votes) 606 views
Custom class generator
Selected snaps:
None selected yet.
Hot PHP snaps
PHP image slideshow auto
PHP pagination class
Bootstrap PHP code
Clean URL
PHP ffmpeg Upload Script
Rijndael 256 bit encryption using mcrypt
generate a preview image from an FLV file on-the-fly, or to save
Median calculator
Partners
PHP Site
PHPSnips
Comments