note 68791 deleted from ref.array by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 19:25:50 +0000 |
| Subject: | note 68791 deleted from ref.array by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134511@lists.php.net to get a copy of this message | ||
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));
}
?>