1--TEST--
2Test krsort() function : usage variations - sort hexadecimal values
3--FILE--
4<?php
5/*
6 * testing krsort() by providing array of hexa-decimal values for $array argument
7 * with following flag values:
8 *  1.flag value as default
9 *  2.SORT_REGULAR - compare items normally
10 *  3.SORT_NUMERIC - compare items numerically
11*/
12
13echo "*** Testing krsort() : usage variations ***\n";
14
15// an array containing unsorted hexadecimal values with keys
16$unsorted_hex_array = array (
17  0x1AB => 0x1AB, 0xFFF => 0xFFF, 0xF => 0xF, 0xFF => 0xFF, 0x2AA => 0x2AA, 0xBB => 0xBB,
18  0x1ab => 0x1ab, 0xff => 0xff, -0xff => -0xFF, 0 => 0, -0x2aa => -0x2aa
19);
20
21echo "\n-- Testing krsort() by supplying hexadecimal value array, 'flag' value is default  --\n";
22$temp_array = $unsorted_hex_array;
23var_dump(krsort( $temp_array) ); // expecting : bool(true)
24var_dump($temp_array);
25
26echo "\n-- Testing krsort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR  --\n";
27$temp_array = $unsorted_hex_array;
28var_dump(krsort( $temp_array, SORT_REGULAR) ); // expecting : bool(true)
29var_dump($temp_array);
30
31echo "\n-- Testing krsort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC  --\n";
32$temp_array = $unsorted_hex_array;
33var_dump(krsort( $temp_array, SORT_NUMERIC) ); // expecting : bool(true)
34var_dump($temp_array);
35
36echo "Done\n";
37?>
38--EXPECT--
39*** Testing krsort() : usage variations ***
40
41-- Testing krsort() by supplying hexadecimal value array, 'flag' value is default  --
42bool(true)
43array(9) {
44  [4095]=>
45  int(4095)
46  [682]=>
47  int(682)
48  [427]=>
49  int(427)
50  [255]=>
51  int(255)
52  [187]=>
53  int(187)
54  [15]=>
55  int(15)
56  [0]=>
57  int(0)
58  [-255]=>
59  int(-255)
60  [-682]=>
61  int(-682)
62}
63
64-- Testing krsort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR  --
65bool(true)
66array(9) {
67  [4095]=>
68  int(4095)
69  [682]=>
70  int(682)
71  [427]=>
72  int(427)
73  [255]=>
74  int(255)
75  [187]=>
76  int(187)
77  [15]=>
78  int(15)
79  [0]=>
80  int(0)
81  [-255]=>
82  int(-255)
83  [-682]=>
84  int(-682)
85}
86
87-- Testing krsort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC  --
88bool(true)
89array(9) {
90  [4095]=>
91  int(4095)
92  [682]=>
93  int(682)
94  [427]=>
95  int(427)
96  [255]=>
97  int(255)
98  [187]=>
99  int(187)
100  [15]=>
101  int(15)
102  [0]=>
103  int(0)
104  [-255]=>
105  int(-255)
106  [-682]=>
107  int(-682)
108}
109Done
110