mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
added krsort() function
This commit is contained in:
parent
3f684e77a7
commit
8638a61df9
@ -2,6 +2,7 @@ PHP 4.0 CHANGE LOG ChangeLog
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
|
||||
?? ?? 1999, Version 4.0 Beta 3
|
||||
- Added krsort() function (Thies)
|
||||
- Added func_num_args(), func_get_arg() and func_get_args() for standard
|
||||
access to variable number of arguments functions (Zeev)
|
||||
- Added FTP support (Andrew Skalski)
|
||||
|
@ -82,6 +82,7 @@ function_entry basic_functions[] = {
|
||||
PHP_FE(usleep, NULL)
|
||||
|
||||
PHP_FE(ksort, first_arg_force_ref)
|
||||
PHP_FE(krsort, first_arg_force_ref)
|
||||
PHP_FE(asort, first_arg_force_ref)
|
||||
PHP_FE(arsort, first_arg_force_ref)
|
||||
PHP_FE(sort, first_arg_force_ref)
|
||||
@ -620,6 +621,10 @@ PHP_FUNCTION(strval)
|
||||
pval_copy_constructor(return_value);
|
||||
}
|
||||
|
||||
static int array_reverse_key_compare(const void *a, const void *b)
|
||||
{ return array_key_compare(a,b)*-1;
|
||||
}
|
||||
|
||||
static int array_key_compare(const void *a, const void *b)
|
||||
{
|
||||
Bucket *first;
|
||||
@ -645,6 +650,29 @@ static int array_key_compare(const void *a, const void *b)
|
||||
}
|
||||
|
||||
|
||||
PHP_FUNCTION(krsort)
|
||||
{
|
||||
pval *array;
|
||||
HashTable *target_hash;
|
||||
|
||||
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
target_hash = HASH_OF(array);
|
||||
if (!target_hash) {
|
||||
php_error(E_WARNING, "Wrong datatype in krsort() call");
|
||||
return;
|
||||
}
|
||||
if (!ParameterPassedByReference(ht,1)) {
|
||||
php_error(E_WARNING, "Array not passed by reference in call to krsort()");
|
||||
return;
|
||||
}
|
||||
if (zend_hash_sort(target_hash, array_reverse_key_compare,0) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
PHP_FUNCTION(ksort)
|
||||
{
|
||||
pval *array;
|
||||
|
@ -51,6 +51,7 @@ PHP_FUNCTION(toggle_short_open_tag);
|
||||
PHP_FUNCTION(sleep);
|
||||
PHP_FUNCTION(usleep);
|
||||
PHP_FUNCTION(ksort);
|
||||
PHP_FUNCTION(krsort);
|
||||
PHP_FUNCTION(asort);
|
||||
PHP_FUNCTION(arsort);
|
||||
PHP_FUNCTION(sort);
|
||||
|
Loading…
Reference in New Issue
Block a user