Home >Backend Development >PHP Tutorial >Function to determine whether a php array is an index array

Function to determine whether a php array is an index array

WBOY
WBOYOriginal
2016-07-25 08:58:521028browse
  1. /**

  2. * Check whether to index the array
  3. * edit bbs.it-home.org
  4. */
  5. function is_assoc($array) {
  6. if(is_array($array)) {
  7. $keys = array_keys($array) ;
  8. return $keys != array_keys($keys);
  9. }
  10. return false;
  11. }

  12. //Call example

  13. echo is_assoc($array)?'Index array':'Not Index array';
  14. ?>

Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn