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