summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2008-12-12 19:20:49 +0000
committerAndrei Zmievski <andrei@php.net>2008-12-12 19:20:49 +0000
commitdddbfccb9fa49d77d5dc556abdf667a016c73065 (patch)
tree2a4079d0ee183fccedf6695a0d396423e9c3f374
parentf6cf54d2b105a625d829f6766cf27b37ed265dc3 (diff)
downloadphp-git-dddbfccb9fa49d77d5dc556abdf667a016c73065.tar.gz
MFH
-rw-r--r--ext/standard/array.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 7c3049e1f4..70966edd88 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2668,7 +2668,7 @@ PHP_FUNCTION(array_change_key_case)
}
/* }}} */
-/* {{{ proto array array_unique(array input)
+/* {{{ proto array array_unique(array input [, int sort_flags])
Removes duplicate values from array */
PHP_FUNCTION(array_unique)
{
@@ -2680,11 +2680,14 @@ PHP_FUNCTION(array_unique)
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
+ long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
return;
}
+ php_set_compare_func(sort_type TSRMLS_CC);
+
array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(array)));
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(array), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
@@ -2703,7 +2706,6 @@ PHP_FUNCTION(array_unique)
arTmp[i].i = i;
}
arTmp[i].b = NULL;
- php_set_compare_func(PHP_SORT_STRING TSRMLS_CC);
zend_qsort((void *) arTmp, i, sizeof(struct bucketindex), php_array_data_compare TSRMLS_CC);
/* go through the sorted array and delete duplicates from the copy */