rsk82 rsk82 - 3 years ago 124
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 Source

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

return ctype_digit(implode('',$array));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download