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
Release: 2016-07-25 08:58:52
Original
1026 people have browsed it
  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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template