| | |
| | | * Parse a human readable string for a number of bytes |
| | | * |
| | | * @param string Input string |
| | | * @return int Number of bytes |
| | | * @return float Number of bytes |
| | | */ |
| | | function parse_bytes($str) |
| | | { |
| | | if (is_numeric($str)) |
| | | return intval($str); |
| | | return floatval($str); |
| | | |
| | | if (preg_match('/([0-9]+)([a-z])/i', $str, $regs)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return intval($bytes); |
| | | return floatval($bytes); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | if ($newlen <= $width) { |
| | | $string .= ($len ? ' ' : '').$line; |
| | | $len += ($len ? 1 : 0) + $l; |
| | | $len += (1 + $l); |
| | | } else { |
| | | if ($l > $width) { |
| | | if ($cut) { |