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