Annotation of embedaddon/php/ext/standard/tests/array/krsort_variation11.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test krsort() function : usage variations - sort bool values
3: --FILE--
4: <?php
5: /* Prototype : bool krsort ( array &$array [, int $sort_flags] )
6: * Description: Sort an array by key in reverse order, maintaining key to data correlation
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * testing krsort() by providing array of boolean values for $array argument with following flag values:
12: * 1.flag value as defualt
13: * 2.SORT_REGULAR - compare items normally
14: */
15:
16: echo "*** Testing krsort() : usage variations ***\n";
17:
18: // bool value array
19: $bool_values = array (true => true, false => false, TRUE => TRUE, FALSE => FALSE);
20:
21: echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is defualt --\n";
22: $temp_array = $bool_values;
23: var_dump(krsort($temp_array) );
24: var_dump($temp_array);
25:
26: echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_REGULAR --\n";
27: $temp_array = $bool_values;
28: var_dump(krsort($temp_array, SORT_REGULAR) );
29: var_dump($temp_array);
30:
31: echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_NUMERIC --\n";
32: $temp_array = $bool_values;
33: var_dump(krsort($temp_array, SORT_NUMERIC) );
34: var_dump($temp_array);
35:
36: echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_STRING --\n";
37: $temp_array = $bool_values;
38: var_dump(krsort($temp_array, SORT_STRING) );
39: var_dump($temp_array);
40:
41: echo "Done\n";
42: ?>
43: --EXPECTF--
44: *** Testing krsort() : usage variations ***
45:
46: -- Testing krsort() by supplying boolean value array, 'flag' value is defualt --
47: bool(true)
48: array(2) {
49: [1]=>
50: bool(true)
51: [0]=>
52: bool(false)
53: }
54:
55: -- Testing krsort() by supplying boolean value array, 'flag' value is SORT_REGULAR --
56: bool(true)
57: array(2) {
58: [1]=>
59: bool(true)
60: [0]=>
61: bool(false)
62: }
63:
64: -- Testing krsort() by supplying boolean value array, 'flag' value is SORT_NUMERIC --
65: bool(true)
66: array(2) {
67: [1]=>
68: bool(true)
69: [0]=>
70: bool(false)
71: }
72:
73: -- Testing krsort() by supplying boolean value array, 'flag' value is SORT_STRING --
74: bool(true)
75: array(2) {
76: [1]=>
77: bool(true)
78: [0]=>
79: bool(false)
80: }
81: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>