High-performance function checks whether specified array contains only integer values (or integer-numeric strings):
/**
* Checks whether all elements of an array are integers (integer value or string with integer value).
* Note: this is very efficient method can be used for array with 10000+ items.
*
* @param int[]|string[] $array One dimensional array to check
*
* @return bool
*/
function hasOnlyIntEntries(array $array)
{
return ctype_digit(join('', $array));
}
Чтобы увидеть комментарии, нужно быть участником сообщества
Регистрация