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