Skip to content

Instantly share code, notes, and snippets.

@oppara
Last active October 25, 2015 06:05
Show Gist options
  • Save oppara/102084 to your computer and use it in GitHub Desktop.
Save oppara/102084 to your computer and use it in GitHub Desktop.
php: is assoc array
<?php
/**
* is assoc array
*
* @see http://jp.php.net/manual/ja/function.is-array.php
* @param array $a
* @access public
* @return bool
*/
function is_assoc_array( $a ) {
return is_array( $a ) && ( count( $a ) !== array_reduce( array_keys( $a ), create_function( '$a, $b', 'return ($b === $a ? $a + 1 : 0);' ), 0 ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment