1--TEST--
2Test str_replace() function - test search values
3--INI--
4precision=14
5--FILE--
6<?php
7echo "\n*** Testing str_replace() with various search values ***";
8$search_arr = array( TRUE, FALSE, 1, 0, -1, "1", "0", "-1",  NULL,
9                     array(), "php", "");
10
11$i = 0;
12/* loop through to replace the matched elements in the array */
13foreach( $search_arr as $value ) {
14  echo "\n-- Iteration $i --\n";
15  /* replace the string in array */
16  var_dump( str_replace($value, "FOUND", $search_arr, $count) );
17  var_dump( $count );
18  $i++;
19}
20
21?>
22--EXPECTF--
23*** Testing str_replace() with various search values ***
24-- Iteration 0 --
25
26Warning: Array to string conversion in %s on line %d
27array(12) {
28  [0]=>
29  string(5) "FOUND"
30  [1]=>
31  string(0) ""
32  [2]=>
33  string(5) "FOUND"
34  [3]=>
35  string(1) "0"
36  [4]=>
37  string(6) "-FOUND"
38  [5]=>
39  string(5) "FOUND"
40  [6]=>
41  string(1) "0"
42  [7]=>
43  string(6) "-FOUND"
44  [8]=>
45  string(0) ""
46  [9]=>
47  string(5) "Array"
48  [10]=>
49  string(3) "php"
50  [11]=>
51  string(0) ""
52}
53int(5)
54
55-- Iteration 1 --
56
57Warning: Array to string conversion in %s on line %d
58array(12) {
59  [0]=>
60  string(1) "1"
61  [1]=>
62  string(0) ""
63  [2]=>
64  string(1) "1"
65  [3]=>
66  string(1) "0"
67  [4]=>
68  string(2) "-1"
69  [5]=>
70  string(1) "1"
71  [6]=>
72  string(1) "0"
73  [7]=>
74  string(2) "-1"
75  [8]=>
76  string(0) ""
77  [9]=>
78  string(5) "Array"
79  [10]=>
80  string(3) "php"
81  [11]=>
82  string(0) ""
83}
84int(0)
85
86-- Iteration 2 --
87
88Warning: Array to string conversion in %s on line %d
89array(12) {
90  [0]=>
91  string(5) "FOUND"
92  [1]=>
93  string(0) ""
94  [2]=>
95  string(5) "FOUND"
96  [3]=>
97  string(1) "0"
98  [4]=>
99  string(6) "-FOUND"
100  [5]=>
101  string(5) "FOUND"
102  [6]=>
103  string(1) "0"
104  [7]=>
105  string(6) "-FOUND"
106  [8]=>
107  string(0) ""
108  [9]=>
109  string(5) "Array"
110  [10]=>
111  string(3) "php"
112  [11]=>
113  string(0) ""
114}
115int(5)
116
117-- Iteration 3 --
118
119Warning: Array to string conversion in %s on line %d
120array(12) {
121  [0]=>
122  string(1) "1"
123  [1]=>
124  string(0) ""
125  [2]=>
126  string(1) "1"
127  [3]=>
128  string(5) "FOUND"
129  [4]=>
130  string(2) "-1"
131  [5]=>
132  string(1) "1"
133  [6]=>
134  string(5) "FOUND"
135  [7]=>
136  string(2) "-1"
137  [8]=>
138  string(0) ""
139  [9]=>
140  string(5) "Array"
141  [10]=>
142  string(3) "php"
143  [11]=>
144  string(0) ""
145}
146int(2)
147
148-- Iteration 4 --
149
150Warning: Array to string conversion in %s on line %d
151array(12) {
152  [0]=>
153  string(1) "1"
154  [1]=>
155  string(0) ""
156  [2]=>
157  string(1) "1"
158  [3]=>
159  string(1) "0"
160  [4]=>
161  string(5) "FOUND"
162  [5]=>
163  string(1) "1"
164  [6]=>
165  string(1) "0"
166  [7]=>
167  string(5) "FOUND"
168  [8]=>
169  string(0) ""
170  [9]=>
171  string(5) "Array"
172  [10]=>
173  string(3) "php"
174  [11]=>
175  string(0) ""
176}
177int(2)
178
179-- Iteration 5 --
180
181Warning: Array to string conversion in %s on line %d
182array(12) {
183  [0]=>
184  string(5) "FOUND"
185  [1]=>
186  string(0) ""
187  [2]=>
188  string(5) "FOUND"
189  [3]=>
190  string(1) "0"
191  [4]=>
192  string(6) "-FOUND"
193  [5]=>
194  string(5) "FOUND"
195  [6]=>
196  string(1) "0"
197  [7]=>
198  string(6) "-FOUND"
199  [8]=>
200  string(0) ""
201  [9]=>
202  string(5) "Array"
203  [10]=>
204  string(3) "php"
205  [11]=>
206  string(0) ""
207}
208int(5)
209
210-- Iteration 6 --
211
212Warning: Array to string conversion in %s on line %d
213array(12) {
214  [0]=>
215  string(1) "1"
216  [1]=>
217  string(0) ""
218  [2]=>
219  string(1) "1"
220  [3]=>
221  string(5) "FOUND"
222  [4]=>
223  string(2) "-1"
224  [5]=>
225  string(1) "1"
226  [6]=>
227  string(5) "FOUND"
228  [7]=>
229  string(2) "-1"
230  [8]=>
231  string(0) ""
232  [9]=>
233  string(5) "Array"
234  [10]=>
235  string(3) "php"
236  [11]=>
237  string(0) ""
238}
239int(2)
240
241-- Iteration 7 --
242
243Warning: Array to string conversion in %s on line %d
244array(12) {
245  [0]=>
246  string(1) "1"
247  [1]=>
248  string(0) ""
249  [2]=>
250  string(1) "1"
251  [3]=>
252  string(1) "0"
253  [4]=>
254  string(5) "FOUND"
255  [5]=>
256  string(1) "1"
257  [6]=>
258  string(1) "0"
259  [7]=>
260  string(5) "FOUND"
261  [8]=>
262  string(0) ""
263  [9]=>
264  string(5) "Array"
265  [10]=>
266  string(3) "php"
267  [11]=>
268  string(0) ""
269}
270int(2)
271
272-- Iteration 8 --
273
274Deprecated: str_replace(): Passing null to parameter #1 ($search) of type array|string is deprecated in %s on line %d
275
276Warning: Array to string conversion in %s on line %d
277array(12) {
278  [0]=>
279  string(1) "1"
280  [1]=>
281  string(0) ""
282  [2]=>
283  string(1) "1"
284  [3]=>
285  string(1) "0"
286  [4]=>
287  string(2) "-1"
288  [5]=>
289  string(1) "1"
290  [6]=>
291  string(1) "0"
292  [7]=>
293  string(2) "-1"
294  [8]=>
295  string(0) ""
296  [9]=>
297  string(5) "Array"
298  [10]=>
299  string(3) "php"
300  [11]=>
301  string(0) ""
302}
303int(0)
304
305-- Iteration 9 --
306
307Warning: Array to string conversion in %s on line %d
308array(12) {
309  [0]=>
310  string(1) "1"
311  [1]=>
312  string(0) ""
313  [2]=>
314  string(1) "1"
315  [3]=>
316  string(1) "0"
317  [4]=>
318  string(2) "-1"
319  [5]=>
320  string(1) "1"
321  [6]=>
322  string(1) "0"
323  [7]=>
324  string(2) "-1"
325  [8]=>
326  string(0) ""
327  [9]=>
328  string(5) "Array"
329  [10]=>
330  string(3) "php"
331  [11]=>
332  string(0) ""
333}
334int(0)
335
336-- Iteration 10 --
337
338Warning: Array to string conversion in %s on line %d
339array(12) {
340  [0]=>
341  string(1) "1"
342  [1]=>
343  string(0) ""
344  [2]=>
345  string(1) "1"
346  [3]=>
347  string(1) "0"
348  [4]=>
349  string(2) "-1"
350  [5]=>
351  string(1) "1"
352  [6]=>
353  string(1) "0"
354  [7]=>
355  string(2) "-1"
356  [8]=>
357  string(0) ""
358  [9]=>
359  string(5) "Array"
360  [10]=>
361  string(5) "FOUND"
362  [11]=>
363  string(0) ""
364}
365int(1)
366
367-- Iteration 11 --
368
369Warning: Array to string conversion in %s on line %d
370array(12) {
371  [0]=>
372  string(1) "1"
373  [1]=>
374  string(0) ""
375  [2]=>
376  string(1) "1"
377  [3]=>
378  string(1) "0"
379  [4]=>
380  string(2) "-1"
381  [5]=>
382  string(1) "1"
383  [6]=>
384  string(1) "0"
385  [7]=>
386  string(2) "-1"
387  [8]=>
388  string(0) ""
389  [9]=>
390  string(5) "Array"
391  [10]=>
392  string(3) "php"
393  [11]=>
394  string(0) ""
395}
396int(0)
397