php - Best way to check if array is numeric -


say have 1 dimensional array of 500,000 cells , want know if array numeric, obvious options either iterate on whole array , use is_numeric() function or use array_shift. problem both of these options o(n) (correct me if i'm wrong) , more expensive data in array grow. i'm thinking of way i'm not sure of o, search non numeric values in array using regex , array_search. think , there less expensive options?

would implode efficient? if have simple array, join elements string , run against is_numeric. @ least have numeric check once.

$foo = array(1, 2, 3, 4, 5, 6, ....); $bar = implode('', $foo);  var_dump(is_numeric($bar)); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -