1--TEST--
2str_word_count()
3--FILE--
4<?php
5error_reporting(E_ALL);
6$str = "Hello friend, you're
7    looking          good today!";
8$b =& $str;
9var_dump(str_word_count($str, 1));
10var_dump(str_word_count($str, 2));
11var_dump(str_word_count($str));
12var_dump(str_word_count($str, 3));
13var_dump(str_word_count($str, 123));
14var_dump(str_word_count($str, -1));
15var_dump(str_word_count($str, 999999999));
16var_dump(str_word_count($str, array()));
17var_dump(str_word_count($str, $b));
18var_dump($str);
19
20$str2 = "F0o B4r 1s bar foo";
21var_dump(str_word_count($str2, NULL, "04"));
22var_dump(str_word_count($str2, NULL, "01"));
23var_dump(str_word_count($str2, NULL, "014"));
24var_dump(str_word_count($str2, NULL, array()));
25var_dump(str_word_count($str2, NULL, new stdClass));
26var_dump(str_word_count($str2, NULL, ""));
27var_dump(str_word_count($str2, 1, "04"));
28var_dump(str_word_count($str2, 1, "01"));
29var_dump(str_word_count($str2, 1, "014"));
30var_dump(str_word_count($str2, 1, array()));
31var_dump(str_word_count($str2, 1, new stdClass));
32var_dump(str_word_count($str2, 1, ""));
33var_dump(str_word_count($str2, 2, "04"));
34var_dump(str_word_count($str2, 2, "01"));
35var_dump(str_word_count($str2, 2, "014"));
36var_dump(str_word_count($str2, 2, array()));
37var_dump(str_word_count($str2, 2, new stdClass));
38var_dump(str_word_count($str2, 2, ""));
39var_dump(str_word_count("foo'0 bar-0var", 2, "0"));
40var_dump(str_word_count("'foo'", 2));
41var_dump(str_word_count("'foo'", 2, "'"));
42var_dump(str_word_count("-foo-", 2));
43var_dump(str_word_count("-foo-", 2, "-"));
44
45echo "Done\n";
46?>
47--EXPECTF--
48array(6) {
49  [0]=>
50  string(5) "Hello"
51  [1]=>
52  string(6) "friend"
53  [2]=>
54  string(6) "you're"
55  [3]=>
56  string(7) "looking"
57  [4]=>
58  string(4) "good"
59  [5]=>
60  string(5) "today"
61}
62array(6) {
63  [0]=>
64  string(5) "Hello"
65  [6]=>
66  string(6) "friend"
67  [14]=>
68  string(6) "you're"
69  [27]=>
70  string(7) "looking"
71  [44]=>
72  string(4) "good"
73  [49]=>
74  string(5) "today"
75}
76int(6)
77
78Warning: str_word_count(): Invalid format value 3 in %s on line %d
79bool(false)
80
81Warning: str_word_count(): Invalid format value 123 in %s on line %d
82bool(false)
83
84Warning: str_word_count(): Invalid format value -1 in %s on line %d
85bool(false)
86
87Warning: str_word_count(): Invalid format value 999999999 in %s on line %d
88bool(false)
89
90Warning: str_word_count() expects parameter 2 to be int, array given in %s on line %d
91NULL
92
93Warning: str_word_count() expects parameter 2 to be int, string given in %s on line %d
94NULL
95string(55) "Hello friend, you're
96    looking          good today!"
97int(5)
98int(6)
99int(5)
100
101Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d
102NULL
103
104Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d
105NULL
106int(7)
107array(5) {
108  [0]=>
109  string(3) "F0o"
110  [1]=>
111  string(3) "B4r"
112  [2]=>
113  string(1) "s"
114  [3]=>
115  string(3) "bar"
116  [4]=>
117  string(3) "foo"
118}
119array(6) {
120  [0]=>
121  string(3) "F0o"
122  [1]=>
123  string(1) "B"
124  [2]=>
125  string(1) "r"
126  [3]=>
127  string(2) "1s"
128  [4]=>
129  string(3) "bar"
130  [5]=>
131  string(3) "foo"
132}
133array(5) {
134  [0]=>
135  string(3) "F0o"
136  [1]=>
137  string(3) "B4r"
138  [2]=>
139  string(2) "1s"
140  [3]=>
141  string(3) "bar"
142  [4]=>
143  string(3) "foo"
144}
145
146Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d
147NULL
148
149Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d
150NULL
151array(7) {
152  [0]=>
153  string(1) "F"
154  [1]=>
155  string(1) "o"
156  [2]=>
157  string(1) "B"
158  [3]=>
159  string(1) "r"
160  [4]=>
161  string(1) "s"
162  [5]=>
163  string(3) "bar"
164  [6]=>
165  string(3) "foo"
166}
167array(5) {
168  [0]=>
169  string(3) "F0o"
170  [4]=>
171  string(3) "B4r"
172  [9]=>
173  string(1) "s"
174  [11]=>
175  string(3) "bar"
176  [15]=>
177  string(3) "foo"
178}
179array(6) {
180  [0]=>
181  string(3) "F0o"
182  [4]=>
183  string(1) "B"
184  [6]=>
185  string(1) "r"
186  [8]=>
187  string(2) "1s"
188  [11]=>
189  string(3) "bar"
190  [15]=>
191  string(3) "foo"
192}
193array(5) {
194  [0]=>
195  string(3) "F0o"
196  [4]=>
197  string(3) "B4r"
198  [8]=>
199  string(2) "1s"
200  [11]=>
201  string(3) "bar"
202  [15]=>
203  string(3) "foo"
204}
205
206Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d
207NULL
208
209Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d
210NULL
211array(7) {
212  [0]=>
213  string(1) "F"
214  [2]=>
215  string(1) "o"
216  [4]=>
217  string(1) "B"
218  [6]=>
219  string(1) "r"
220  [9]=>
221  string(1) "s"
222  [11]=>
223  string(3) "bar"
224  [15]=>
225  string(3) "foo"
226}
227array(2) {
228  [0]=>
229  string(5) "foo'0"
230  [6]=>
231  string(8) "bar-0var"
232}
233array(1) {
234  [1]=>
235  string(4) "foo'"
236}
237array(1) {
238  [0]=>
239  string(5) "'foo'"
240}
241array(1) {
242  [1]=>
243  string(3) "foo"
244}
245array(1) {
246  [0]=>
247  string(5) "-foo-"
248}
249Done
250