From: Andrei Zmievski Date: Fri, 27 Oct 2000 14:08:33 +0000 (+0000) Subject: @- Fixed array_rand() to shuffle results when the number of requested X-Git-Tag: php-4.0.4RC3~493 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4cf62f86fd96ed21bb0069fb540747170499a35;p=php @- Fixed array_rand() to shuffle results when the number of requested @ elements is the same as the number of elements in the array. (Andrei) --- 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; + } } } /* }}} */