rsk82 rsk82 - 1 month ago 9
PHP Question

What is the Quickest Way to Check If All Values in an Array Are Numeric?

I must check big arrays to see if they are 100% filled with numeric values.
The only way that comes to my mind is foreach and then is_numeric for every value, but is that the fastest way?

Answer

assuming your array is one-dimensional and just made up of integers:

return ctype_digit(implode('',$array));