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