1--TEST--
2Test array_replace and array_replace_recursive
3--FILE--
4<?php
5
6$array1 = array(
7	0 => 'dontclobber',
8	'1' => 'unclobbered',
9	'test2' => 0.0,
10	'test3' => array(
11		'testarray2' => true,
12		1 => array(
13			'testsubarray1' => 'dontclobber2',
14			'testsubarray2' => 'dontclobber3',
15	),
16    ),
17);
18
19$array2 = array(
20	1 => 'clobbered',
21	'test3' => array(
22		'testarray2' => false,
23	),
24	'test4' => array(
25		'clobbered3' => array(0, 1, 2),
26	),
27);
28
29$array3 = array(array(array(array())));
30
31$array4 = array();
32$array4[] = &$array4;
33
34echo " -- Testing array_replace() --\n";
35$data = array_replace($array1, $array2);
36
37var_dump($data);
38
39echo " -- Testing array_replace_recursive() --\n";
40$data = array_replace_recursive($array1, $array2);
41
42var_dump($data);
43
44echo " -- Testing array_replace_recursive() w/ endless recusrsion --\n";
45$data = array_replace_recursive($array3, $array4);
46
47var_dump($data);
48?>
49--EXPECTF--
50 -- Testing array_replace() --
51array(5) {
52  [0]=>
53  string(11) "dontclobber"
54  [1]=>
55  string(9) "clobbered"
56  ["test2"]=>
57  float(0)
58  ["test3"]=>
59  array(1) {
60    ["testarray2"]=>
61    bool(false)
62  }
63  ["test4"]=>
64  array(1) {
65    ["clobbered3"]=>
66    array(3) {
67      [0]=>
68      int(0)
69      [1]=>
70      int(1)
71      [2]=>
72      int(2)
73    }
74  }
75}
76 -- Testing array_replace_recursive() --
77array(5) {
78  [0]=>
79  string(11) "dontclobber"
80  [1]=>
81  string(9) "clobbered"
82  ["test2"]=>
83  float(0)
84  ["test3"]=>
85  array(2) {
86    ["testarray2"]=>
87    bool(false)
88    [1]=>
89    array(2) {
90      ["testsubarray1"]=>
91      string(12) "dontclobber2"
92      ["testsubarray2"]=>
93      string(12) "dontclobber3"
94    }
95  }
96  ["test4"]=>
97  array(1) {
98    ["clobbered3"]=>
99    array(3) {
100      [0]=>
101      int(0)
102      [1]=>
103      int(1)
104      [2]=>
105      int(2)
106    }
107  }
108}
109 -- Testing array_replace_recursive() w/ endless recusrsion --
110
111Warning: array_replace_recursive(): recursion detected in %s on line %d
112array(1) {
113  [0]=>
114  array(1) {
115    [0]=>
116    array(1) {
117      [0]=>
118      array(0) {
119      }
120    }
121  }
122}
123