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