Index: ext/standard/array.c =================================================================== RCS file: /repository/php-src/ext/standard/array.c,v retrieving revision 1.300 diff -u -r1.300 array.c --- ext/standard/array.c 8 Jun 2005 19:54:24 -0000 1.300 +++ ext/standard/array.c 12 Jun 2005 20:16:18 -0000 @@ -4474,6 +4474,47 @@ } /* }}} */ +/* {{{ proto boolean array_is_numeric(array array, int start = null) + Determines whether an array is numerically indexed (thus not a hash) */ +PHP_FUNCTION(array_is_numeric) +{ + zval *array; + int start, type; + HashPosition pos; + char *str; + uint strlen; + ulong index; + + start= 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &start) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter must be an array!"); + return; + } + + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(array), &pos); + while (HASH_KEY_NON_EXISTANT != (type= zend_hash_get_current_key_type_ex(Z_ARRVAL_P(array), &pos))) { + if (HASH_KEY_IS_LONG != type) { + RETURN_FALSE; + } + + if (zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &str, &strlen, &index, 0, &pos) == FAILURE) { + RETURN_FALSE; + } + + if (start != index) { + RETURN_FALSE; + } + + start++; + zend_hash_move_forward_ex(Z_ARRVAL_P(array), &pos); + } + + RETURN_TRUE; +} +/* }}} */ + + /* * Local variables: * tab-width: 4 Index: ext/standard/basic_functions.c =================================================================== RCS file: /repository/php-src/ext/standard/basic_functions.c,v retrieving revision 1.718 diff -u -r1.718 basic_functions.c --- ext/standard/basic_functions.c 24 May 2005 15:21:18 -0000 1.718 +++ ext/standard/basic_functions.c 12 Jun 2005 20:16:19 -0000 @@ -816,6 +816,7 @@ PHP_FE(array_chunk, NULL) PHP_FE(array_combine, NULL) PHP_FE(array_key_exists, NULL) + PHP_FE(array_is_numeric, NULL) /* aliases from array.c */ PHP_FALIAS(pos, current, first_arg_force_ref) Index: ext/standard/php_array.h =================================================================== RCS file: /repository/php-src/ext/standard/php_array.h,v retrieving revision 1.49 diff -u -r1.49 php_array.h --- ext/standard/php_array.h 11 May 2005 11:43:11 -0000 1.49 +++ ext/standard/php_array.h 12 Jun 2005 20:16:19 -0000 @@ -98,6 +98,7 @@ PHP_FUNCTION(array_key_exists); PHP_FUNCTION(array_chunk); PHP_FUNCTION(array_combine); +PHP_FUNCTION(array_is_numeric); HashTable* php_splice(HashTable *, int, int, zval ***, int, HashTable **); PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC);