Number
class Number (View source)
Methods
Rounds the value only out to its most significant digit.
Remove superfluous zeroes from a string containing a number.
Checks if a given string is valid representation of a number in the current locale.
Checks if a given string is valid representation of an integer in the current locale.
Format a number with grouped thousands and localized decimal point/thousands separator.
Parses a localized number representation and returns the number (or null if $string is not a valid number representation).
Formats a size (measured in bytes, KB, MB, ...).
Nice and elegant function for converting memory. Thanks to @lightness races in orbit on Stackoverflow.
Details
float|null
flexround(string $value)
Rounds the value only out to its most significant digit.
string
trim(string $value)
Remove superfluous zeroes from a string containing a number.
bool
isNumber($string)
Checks if a given string is valid representation of a number in the current locale.
bool
isInteger($string)
Checks if a given string is valid representation of an integer in the current locale.
string
format(number $number, int|null $precision = null)
Format a number with grouped thousands and localized decimal point/thousands separator.
null|number
unformat(string $string, bool $trim = true, int|null $precision = null)
Parses a localized number representation and returns the number (or null if $string is not a valid number representation).
string|mixed
formatSize(number $size, string $forceUnit = '')
Formats a size (measured in bytes, KB, MB, ...).
int|string
getBytes($val)
Nice and elegant function for converting memory. Thanks to @lightness races in orbit on Stackoverflow.