mirror of
https://github.com/php/php-src.git
synced 2025-01-27 14:13:41 +08:00
@- Fixed array_rand() to shuffle results when the number of requested
@ elements is the same as the number of elements in the array. (Andrei)
This commit is contained in:
parent
b522397298
commit
d4cf62f86f
@ -2764,6 +2764,13 @@ PHP_FUNCTION(array_rand)
|
||||
|
||||
num_avail--;
|
||||
zend_hash_move_forward(Z_ARRVAL_PP(input));
|
||||
}
|
||||
|
||||
if (num_req_val == num_avail) {
|
||||
if (zend_hash_sort(Z_ARRVAL_P(return_value), (sort_func_t)mergesort, array_data_shuffle, 1) == FAILURE) {
|
||||
zval_dtor(return_value);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user