[Edit] Conversion SizeTo Detailed B, KB, MB, GB, TB
Exampleecho filesize_tag(123456); // 120 KB echo filesize_tag(123456789); // 117 MB echo filesize_tag(12345,true); // 12 KB, 57 B echo filesize_tag(filesize('somefile.txt')); // size of the file... function filesize_tag($size,$full=false){ $sizes = array(); $tags = array(' B', ' KB', ' MB', ' GB', ' TB'); $i = 0; $sizes[$i] = $size; $i++; while($size > 1024){ $size = floor($size / 1024); $sizes[$i] = $size; $i++; } foreach($sizes as $key=>$size){ $subtract = array_key_exists(($key + 1), $sizes) ? $sizes[$key + 1] * 1024 : 0; $sizes[$key] = $sizes[$key] - $subtract . $tags[$key]; } return $full ? implode(', ',array_reverse($sizes)) : $sizes[sizeof($sizes) - 1]; } |
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
© Advanced Web Core. All rights reserved