1--TEST--
2Test uasort() function : usage variations - sort array with reference variables
3--FILE--
4<?php
5/*
6* Testing uasort() with 'array_arg' containing different reference variables
7*/
8
9// comparison function
10function cmp_function($value1, $value2)
11{
12  if($value1 == $value2) {
13    return 0;
14  }
15  else if($value1 > $value2) {
16    return 1;
17  }
18  else {
19    return -1;
20  }
21}
22
23echo "*** Testing uasort() : 'array_arg' with elements as reference ***\n";
24
25// different variables which are used as elements of 'array_arg'
26$value1 = -5;
27$value2 = 100;
28$value3 = 0;
29$value4 = &$value1;
30
31// array_args an array containing elements with reference variables
32$array_arg = array(
33  0 => 10,
34  1 => &$value4,
35  2 => &$value2,
36  3 => 200,
37  4 => &$value3,
38);
39
40echo "-- Sorting 'array_arg' containing different references --\n";
41var_dump( uasort($array_arg, 'cmp_function') );  // expecting: bool(true)
42var_dump($array_arg);
43
44echo "Done"
45?>
46--EXPECT--
47*** Testing uasort() : 'array_arg' with elements as reference ***
48-- Sorting 'array_arg' containing different references --
49bool(true)
50array(5) {
51  [1]=>
52  &int(-5)
53  [4]=>
54  &int(0)
55  [0]=>
56  int(10)
57  [2]=>
58  &int(100)
59  [3]=>
60  int(200)
61}
62Done
63