File: array_change_key_case_variation8.phpt

package info (click to toggle)
php5 5.3.3-7%2Bsqueeze17
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 122,824 kB
  • ctags: 55,742
  • sloc: ansic: 633,963; php: 19,620; sh: 11,344; xml: 5,816; cpp: 2,400; yacc: 1,745; exp: 1,514; makefile: 1,019; pascal: 623; awk: 537; sql: 22
file content (128 lines) | stat: -rw-r--r-- 2,093 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
--TEST--
Test array_change_key_case() function : usage variations - Different strings as keys
--FILE--
<?php
/* Prototype  : array array_change_key_case(array $input [, int $case])
 * Description: Retuns an array with all string keys lowercased [or uppercased] 
 * Source code: ext/standard/array.c
 */

/*
 * Test how array_change_key_case() behaves with different strings
 */

echo "*** Testing array_change_key_case() : usage variations ***\n";

$inputs = array (
	// group of escape sequences
	array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11),

	// array contains combination of capital/small letters
	array("lemoN" => 1, "Orange" => 2, "banana" => 3, "apple" => 4, "Test" => 5, "TTTT" => 6, "ttt" => 7, "ww" => 8, "x" => 9, "X" => 10, "oraNGe" => 11, "BANANA" => 12)
);

foreach($inputs as $input) {
	echo "\n-- \$case = default --\n";
	var_dump(array_change_key_case($input));
	echo "-- \$case = upper --\n";
	var_dump(array_change_key_case($input, CASE_UPPER));
}

echo "Done";
?>

--EXPECTF--
*** Testing array_change_key_case() : usage variations ***

-- $case = default --
array(10) {
  [""]=>
  int(2)
  ["\a"]=>
  int(3)
  ["\cx"]=>
  int(4)
  ["\e"]=>
  int(5)
  [""]=>
  int(6)
  ["
"]=>
  int(7)
  ["	"]=>
  int(8)
  ["\xhh"]=>
  int(9)
  ["\ddd"]=>
  int(10)
  [""]=>
  int(11)
}
-- $case = upper --
array(10) {
  [""]=>
  int(2)
  ["\A"]=>
  int(3)
  ["\CX"]=>
  int(4)
  ["\E"]=>
  int(5)
  [""]=>
  int(6)
  ["
"]=>
  int(7)
  ["	"]=>
  int(8)
  ["\XHH"]=>
  int(9)
  ["\DDD"]=>
  int(10)
  [""]=>
  int(11)
}

-- $case = default --
array(9) {
  ["lemon"]=>
  int(1)
  ["orange"]=>
  int(11)
  ["banana"]=>
  int(12)
  ["apple"]=>
  int(4)
  ["test"]=>
  int(5)
  ["tttt"]=>
  int(6)
  ["ttt"]=>
  int(7)
  ["ww"]=>
  int(8)
  ["x"]=>
  int(10)
}
-- $case = upper --
array(9) {
  ["LEMON"]=>
  int(1)
  ["ORANGE"]=>
  int(11)
  ["BANANA"]=>
  int(12)
  ["APPLE"]=>
  int(4)
  ["TEST"]=>
  int(5)
  ["TTTT"]=>
  int(6)
  ["TTT"]=>
  int(7)
  ["WW"]=>
  int(8)
  ["X"]=>
  int(10)
}
Done