1--TEST--
2Test uasort() function : basic functionality - duplicate values
3--FILE--
4<?php
5echo "*** Testing uasort() : basic functionality with duplicate values ***\n";
6
7// comparison function
8function cmp($value1, $value2)
9{
10  if($value1 == $value2) {
11    return 0;
12  }
13  else if($value1 > $value2) {
14    return 1;
15  }
16  else
17    return -1;
18}
19
20// increasing values
21$int_values1 = array(1, 1, 2, 2, 3, 3);
22echo "-- Numeric array with increasing values --\n";
23var_dump( uasort($int_values1, 'cmp') );
24var_dump($int_values1);
25
26// decreasing values
27$int_values2 = array(3, 3, 2, 2, 1, 1);
28echo "-- Numeric array with decreasing values --\n";
29var_dump( uasort($int_values2, 'cmp') );
30var_dump($int_values2);
31
32// increasing and decreasing values
33$int_values3 = array(1, 2, 3, 3, 2, 1);
34echo "-- Numeric array with increasing and decreasing values --\n";
35var_dump( uasort($int_values3, 'cmp') );
36var_dump($int_values3);
37
38echo "Done"
39?>
40--EXPECT--
41*** Testing uasort() : basic functionality with duplicate values ***
42-- Numeric array with increasing values --
43bool(true)
44array(6) {
45  [0]=>
46  int(1)
47  [1]=>
48  int(1)
49  [2]=>
50  int(2)
51  [3]=>
52  int(2)
53  [4]=>
54  int(3)
55  [5]=>
56  int(3)
57}
58-- Numeric array with decreasing values --
59bool(true)
60array(6) {
61  [4]=>
62  int(1)
63  [5]=>
64  int(1)
65  [2]=>
66  int(2)
67  [3]=>
68  int(2)
69  [0]=>
70  int(3)
71  [1]=>
72  int(3)
73}
74-- Numeric array with increasing and decreasing values --
75bool(true)
76array(6) {
77  [0]=>
78  int(1)
79  [5]=>
80  int(1)
81  [1]=>
82  int(2)
83  [4]=>
84  int(2)
85  [2]=>
86  int(3)
87  [3]=>
88  int(3)
89}
90Done
91