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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -