static function is_associative_array($a, $ifEmptyAssociativeArray = false)
	{
        if( !is_array($a) )
            return false;
        if ( count($a) == 0 )
            return $ifEmptyAssociativeArray;
        
		// firstly, verify that all keys are ints ; if not, the array is associative
		$keys = array_keys($a);
		foreach ( $keys as $k )
			if ( !is_int($k) )
				return true;
				
        // if all keys are numeric, they must follow themselves : e.g. 0, 1, 2, 3 is OK, but 0, 3, 4 is NOT OK.
		return max($keys)+1 != count($a);
	}
static function is_associative_array($a, $ifEmptyAssociativeArray = false)
	{
        if( !is_array($a) )
            return false;
        if ( count($a) == 0 )
            return $ifEmptyAssociativeArray;
        
		// firstly, verify that all keys are ints ; if not, the array is associative
		$keys = array_keys($a);
		foreach ( $keys as $k )
			if ( !is_int($k) )
				return true;
				
        // if all keys are numeric, they must follow themselves : e.g. 0, 1, 2, 3 is OK, but 0, 3, 4 is NOT OK.
		return max($keys)+1 != count($a);
	}
static function is_associative_array ( $ a , $ ifEmptyAssociativeArray = false ) { if ( ! is_array ( $ a ) ) return false ; if ( count ( $ a ) == 0 ) return $ ifEmptyAssociativeArray ; // firstly, verify that all keys are ints ; if not, the array is associative $ keys = array_keys ( $ a ) ; foreach ( $ keys as $ k ) if ( ! is_int ( $ k ) ) return true ; // if all keys are numeric, they must follow themselves : e.g. 0, 1, 2, 3 is OK, but 0, 3, 4 is NOT OK. return max ( $ keys ) + 1 != count ( $ a ) ; }
Test if a given array is associative or has only numeric keys

@param mixed[] $a Array to test
@param bool $ifEmptyAssociativeArray If $a is an empty array, we can return true or false, depending on this optionnal parameter
@return bool True if array $a is associative, false otherwise
Test if a given array is associative or has only numeric keys