1--TEST--
2Test uasort() function : usage variations - different associative arrays
3--FILE--
4<?php
5/* Testing uasort() with different associative arrays having keys as
6 *   string, integer, default & duplicate keys
7 */
8
9echo "*** Testing uasort() : sorting different associative arrays ***\n";
10
11// comparison function
12function cmp($value1, $value2)
13{
14  if($value1 == $value2) {
15    return 0;
16  }
17  else if($value1 > $value2) {
18    return 1;
19  }
20  else
21    return -1;
22}
23
24// Array with duplicate string and integer keys
25$array_arg = array(0 => 2, "a" => 8, "d" => 9, 3 => 3, 5 => 2, "o" => 6, "z" => -99, 0 => 1, "z" => 3);
26echo "-- Array with duplicate keys --\n";
27var_dump( uasort($array_arg, 'cmp') );
28var_dump($array_arg);
29
30// Array with default and assigned keys
31$array_arg = array(0 => "Banana", 1 => "Mango", "Orange", 2 => "Apple", "Pineapple");
32echo "-- Array with default/assigned keys --\n";
33var_dump( uasort($array_arg, 'cmp') );
34var_dump($array_arg);
35
36echo "Done"
37?>
38--EXPECT--
39*** Testing uasort() : sorting different associative arrays ***
40-- Array with duplicate keys --
41bool(true)
42array(7) {
43  [0]=>
44  int(1)
45  [5]=>
46  int(2)
47  [3]=>
48  int(3)
49  ["z"]=>
50  int(3)
51  ["o"]=>
52  int(6)
53  ["a"]=>
54  int(8)
55  ["d"]=>
56  int(9)
57}
58-- Array with default/assigned keys --
59bool(true)
60array(4) {
61  [2]=>
62  string(5) "Apple"
63  [0]=>
64  string(6) "Banana"
65  [1]=>
66  string(5) "Mango"
67  [3]=>
68  string(9) "Pineapple"
69}
70Done
71