1--TEST--
2Test asort() function : usage variations - sort reference variables
3--FILE--
4<?php
5/*
6 * Testing asort() 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 asort() :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 asort() by supplying reference variable array, 'flag' value is default --\n";
22$temp_array = $unsorted_numerics;
23var_dump( asort($temp_array) ); // expecting : bool(true)
24var_dump( $temp_array);
25
26echo "\n-- Testing asort() by supplying reference variable array, 'flag' = SORT_REGULAR --\n";
27$temp_array = &$unsorted_numerics;
28var_dump( asort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
29var_dump( $temp_array);
30
31echo "\n-- Testing asort() by supplying reference variable array, 'flag' = SORT_NUMERIC --\n";
32$temp_array = &$unsorted_numerics;
33var_dump( asort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
34var_dump( $temp_array);
35
36echo "Done\n";
37?>
38--EXPECT--
39*** Testing asort() :usage variations  ***
40
41-- Testing asort() by supplying reference variable array, 'flag' value is default --
42bool(true)
43array(3) {
44  [2]=>
45  &int(33)
46  [1]=>
47  &int(100)
48  [3]=>
49  &int(555)
50}
51
52-- Testing asort() by supplying reference variable array, 'flag' = SORT_REGULAR --
53bool(true)
54array(3) {
55  [2]=>
56  &int(33)
57  [1]=>
58  &int(100)
59  [3]=>
60  &int(555)
61}
62
63-- Testing asort() by supplying reference variable array, 'flag' = SORT_NUMERIC --
64bool(true)
65array(3) {
66  [2]=>
67  &int(33)
68  [1]=>
69  &int(100)
70  [3]=>
71  &int(555)
72}
73Done
74