From d4cf62f86fd96ed21bb0069fb540747170499a35 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Fri, 27 Oct 2000 14:08:33 +0000 Subject: [PATCH] @- Fixed array_rand() to shuffle results when the number of requested @ elements is the same as the number of elements in the array. (Andrei) --- ext/standard/array.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/standard/array.c b/ext/standard/array.c index 80a2239572..1478da640b 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -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; + } } } /* }}} */ -- 2.50.1