Skip to content

Instantly share code, notes, and snippets.

@montchr
Last active August 29, 2015 14:14
Show Gist options
  • Save montchr/1ee4ceac4c955a8423fb to your computer and use it in GitHub Desktop.
Save montchr/1ee4ceac4c955a8423fb to your computer and use it in GitHub Desktop.
PHP check for array type
<?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