xref: /PHP-8.4/ext/standard/tests/array/bug34982.phpt (revision 610c7fbe)
1--TEST--
2Bug #34982 (array_walk_recursive() modifies elements outside function scope)
3--FILE--
4<?php
5$ar = array(
6    'element 1',
7    array('subelement1')
8    );
9
10func($ar);
11print_r($ar);
12
13function func($a) {
14  array_walk_recursive($a, 'apply');
15  print_r($a);
16}
17
18function apply(&$input, $key) {
19  $input = 'changed';
20}
21?>
22--EXPECT--
23Array
24(
25    [0] => changed
26    [1] => Array
27        (
28            [0] => changed
29        )
30
31)
32Array
33(
34    [0] => element 1
35    [1] => Array
36        (
37            [0] => subelement1
38        )
39
40)
41