1--TEST--
2Test arsort() function : usage variations - sort reference variables
3--FILE--
4<?php
5/* Prototype  : bool arsort ( array &$array [, int $sort_flags] )
6 * Description: Sort an array and maintain index association.
7                Elements will be arranged from highest to lowest when this function has completed.
8 * Source code: ext/standard/array.c
9*/
10
11/*
12 * Testing arsort() by providing reference variable array with following flag values
13 *  flag value as defualt
14 *  SORT_REGULAR - compare items normally
15 *  SORT_NUMERIC - compare items numerically
16*/
17
18echo "*** Testing arsort() :usage variations  ***\n";
19
20$value1 = 100;
21$value2 = 33;
22$value3 = 555;
23
24// an array containing integer references
25$unsorted_numerics =  array( 1 => &$value1 , 2 => &$value2, 3 => &$value3);
26
27echo "\n-- Testing arsort() by supplying reference variable array, 'flag' value is defualt --\n";
28$temp_array = $unsorted_numerics;
29var_dump( arsort($temp_array) ); // expecting : bool(true)
30var_dump( $temp_array);
31
32echo "\n-- Testing arsort() by supplying reference variable array, 'flag' = SORT_REGULAR --\n";
33$temp_array = &$unsorted_numerics;
34var_dump( arsort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
35var_dump( $temp_array);
36
37echo "\n-- Testing arsort() by supplying reference variable array, 'flag' = SORT_NUMERIC --\n";
38$temp_array = &$unsorted_numerics;
39var_dump( arsort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
40var_dump( $temp_array);
41
42echo "Done\n";
43?>
44--EXPECT--
45*** Testing arsort() :usage variations  ***
46
47-- Testing arsort() by supplying reference variable array, 'flag' value is defualt --
48bool(true)
49array(3) {
50  [3]=>
51  &int(555)
52  [1]=>
53  &int(100)
54  [2]=>
55  &int(33)
56}
57
58-- Testing arsort() by supplying reference variable array, 'flag' = SORT_REGULAR --
59bool(true)
60array(3) {
61  [3]=>
62  &int(555)
63  [1]=>
64  &int(100)
65  [2]=>
66  &int(33)
67}
68
69-- Testing arsort() by supplying reference variable array, 'flag' = SORT_NUMERIC --
70bool(true)
71array(3) {
72  [3]=>
73  &int(555)
74  [1]=>
75  &int(100)
76  [2]=>
77  &int(33)
78}
79Done
80