Last active
August 29, 2015 14:14
-
-
Save montchr/1ee4ceac4c955a8423fb to your computer and use it in GitHub Desktop.
PHP check for array type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check to see if the supplied array is associative. | |
* | |
* @link http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential | |
* @return bool True if is associative, false if non-associative. | |
*/ | |
function is_assoc($array) { | |
return (bool)count(array_filter(array_keys($array), 'is_string')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment