note 68791 deleted from ref.array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: Nicolai Bloch 

----

Here are two functions for checking if an array contains numeric or string indexes only.
Hope someone else will find them useful.

<?php
//Check for numeric array
function isNumeric($ar) {
  $keys = array_keys($ar);
  natsort($keys); //String keys will be last
  return is_int(array_pop($keys));
}

//Check for associative array
function isAssoc($ar) {
  $keys = array_keys($ar);
  natsort($keys); //Numeric keys will be first
  return is_string(array_shift($keys));
}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.