The number helper contains methods that can be useful when working with numbers.
Convert bytes in 'kb','mb','gb','tb','pb'
echo Number::byteFormat(10000);
Converts a number into a more readable human-type number.
echo Number::quantity(7000); // 7K echo Number::quantity(7500); // 8K echo Number::quantity(7500, 1); // 7.5K
Checks if the value is between the minimum and maximum (min & max included).
if (Number::between(2, 10, 5)) {
// do something...
}
Checks the value for an even number.
if (Number::even(2)) {
// do something...
}
Checks if the value is greather than a given minimum.
if (Number::greaterThan(2, 10)) {
// do something...
}
Checks if the value is smaller than a given maximum.
if (Number::smallerThan(2, 10)) {
// do something...
}
Checks if the value is not greater than or equal a given maximum.
if (Number::maximum(2, 10)) {
// do something...
}
Checks if the value is greater than or equal to a given minimum.
if (Number::minimum(2, 10)) {
// do something...
}
Checks if the value is greater than or equal to a given minimum.
if (Number::odd(2)) {
// do something...
}