Для получения полного доступа
зарегистрируйтесь.
RSS

All snippets tagged with "integer value array" tag



IStranger
  • Reputation: 17
  • Snippets: 8
  • Revisions: 0

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));
}