method isNumber documentation in bbn\Str

Checks if the item is a number.

Can take as many arguments and will return false if one of them is not a number.

Example

X::dump(\bbn\Str::isNumber([1, 2])); // (bool) false X::dump(\bbn\Str::isNumber(150); // (bool) 1 X::dump(\bbn\Str::isNumber('150')); // (bool) 1 X::dump(\bbn\Str::isNumber(1.5); // (bool) 1 function() { if (empty($args = \func_get_args())) { return false; } foreach ($args as $a){ if (\is_string($a)) { if (!preg_match('/^-?(?:\d+|\d*\.\d+)$/', $a)) { return false; } } elseif (!\is_int($a) && !\is_float($a)) { return false; } } return true; }

Checks if the item is a number. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.