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 $string)
Checks if a given string is valid representation of a number in the current locale.
bool
isInteger(int|float|string $string)
Checks if a given string is valid representation of an integer in the current locale.
string
format(int|float|string $number, int|null $precision = null)
Format a number with grouped thousands and localized decimal point/thousands separator.
int|float|null
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(int|float|string $size, string $forceUnit = '')
Formats a size (measured in bytes, KB, MB, ...).
int|string
getBytes(string $val)
Nice and elegant function for converting memory. Thanks to @lightness races in orbit on Stackoverflow.