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