Capacity unit calculation supports defining the decimal retention length; defining the starting and target units, or automatically carrying according to 1024
class Util { /**- * Capacity unit calculation, supports the definition of decimal retention length; defines the starting and target units, or automatically carries by 1024
- ’ Capacity unit’s Bytes
- * @param type $decimals, the number of digits retained after the decimal point, one digit is reserved by default
- * @param type $targetUnit, the target unit of conversion, automatic carry by default
- * @return type Returns the result with units that meets the requirements
- */
- static function fileSizeConv($size, $unit = 'B', $decimals = 1, $targetUnit = 'auto') {
- $units = array ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
- $theUnit = array_search(strtoupper($unit), $units); //Initial unit Which
- // Determine whether to calculate automatically,
- ;= 1024) {
- $size/=1024;
- break;
" "
-
-
-
-
-
-
-
|