1--TEST--
2Test uasort() function : usage variations - sort array having subarrays
3--FILE--
4<?php
5/*
6* Testing uasort() with 'array_arg' having different subarrays as array elements
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() : sorting array having different subarrays ***\n";
24
25$array_args = array(
26  0 => array(2, 10, -1),
27  1 => array(100),
28  2 => array(),
29  3 => array(0),
30  4 => array(-1),
31  5 => array(-9, 34, 54, 0, 20),
32  6 => array(''),
33  7 => array("apple", "Apple", "APPLE", "aPPle", "aPpLe")
34);
35$temp_array = $array_args;
36// sorting array_arg as whole array
37var_dump( uasort($temp_array, 'cmp_function') );  // expecting: bool(true)
38var_dump($temp_array);
39
40?>
41--EXPECT--
42*** Testing uasort() : sorting array having different subarrays ***
43bool(true)
44array(8) {
45  [2]=>
46  array(0) {
47  }
48  [6]=>
49  array(1) {
50    [0]=>
51    string(0) ""
52  }
53  [4]=>
54  array(1) {
55    [0]=>
56    int(-1)
57  }
58  [3]=>
59  array(1) {
60    [0]=>
61    int(0)
62  }
63  [1]=>
64  array(1) {
65    [0]=>
66    int(100)
67  }
68  [0]=>
69  array(3) {
70    [0]=>
71    int(2)
72    [1]=>
73    int(10)
74    [2]=>
75    int(-1)
76  }
77  [5]=>
78  array(5) {
79    [0]=>
80    int(-9)
81    [1]=>
82    int(34)
83    [2]=>
84    int(54)
85    [3]=>
86    int(0)
87    [4]=>
88    int(20)
89  }
90  [7]=>
91  array(5) {
92    [0]=>
93    string(5) "apple"
94    [1]=>
95    string(5) "Apple"
96    [2]=>
97    string(5) "APPLE"
98    [3]=>
99    string(5) "aPPle"
100    [4]=>
101    string(5) "aPpLe"
102  }
103}
104