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
274Warning: Array to string conversion in %s on line %d
275array(12) {
276  [0]=>
277  string(1) "1"
278  [1]=>
279  string(0) ""
280  [2]=>
281  string(1) "1"
282  [3]=>
283  string(1) "0"
284  [4]=>
285  string(2) "-1"
286  [5]=>
287  string(1) "1"
288  [6]=>
289  string(1) "0"
290  [7]=>
291  string(2) "-1"
292  [8]=>
293  string(0) ""
294  [9]=>
295  string(5) "Array"
296  [10]=>
297  string(3) "php"
298  [11]=>
299  string(0) ""
300}
301int(0)
302
303-- Iteration 9 --
304
305Warning: Array to string conversion in %s on line %d
306array(12) {
307  [0]=>
308  string(1) "1"
309  [1]=>
310  string(0) ""
311  [2]=>
312  string(1) "1"
313  [3]=>
314  string(1) "0"
315  [4]=>
316  string(2) "-1"
317  [5]=>
318  string(1) "1"
319  [6]=>
320  string(1) "0"
321  [7]=>
322  string(2) "-1"
323  [8]=>
324  string(0) ""
325  [9]=>
326  string(5) "Array"
327  [10]=>
328  string(3) "php"
329  [11]=>
330  string(0) ""
331}
332int(0)
333
334-- Iteration 10 --
335
336Warning: Array to string conversion in %s on line %d
337array(12) {
338  [0]=>
339  string(1) "1"
340  [1]=>
341  string(0) ""
342  [2]=>
343  string(1) "1"
344  [3]=>
345  string(1) "0"
346  [4]=>
347  string(2) "-1"
348  [5]=>
349  string(1) "1"
350  [6]=>
351  string(1) "0"
352  [7]=>
353  string(2) "-1"
354  [8]=>
355  string(0) ""
356  [9]=>
357  string(5) "Array"
358  [10]=>
359  string(5) "FOUND"
360  [11]=>
361  string(0) ""
362}
363int(1)
364
365-- Iteration 11 --
366
367Warning: Array to string conversion in %s on line %d
368array(12) {
369  [0]=>
370  string(1) "1"
371  [1]=>
372  string(0) ""
373  [2]=>
374  string(1) "1"
375  [3]=>
376  string(1) "0"
377  [4]=>
378  string(2) "-1"
379  [5]=>
380  string(1) "1"
381  [6]=>
382  string(1) "0"
383  [7]=>
384  string(2) "-1"
385  [8]=>
386  string(0) ""
387  [9]=>
388  string(5) "Array"
389  [10]=>
390  string(3) "php"
391  [11]=>
392  string(0) ""
393}
394int(0)
395