summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2005-10-28 10:06:43 +0000
committerDmitry Stogov <dmitry@php.net>2005-10-28 10:06:43 +0000
commita3cb94abff0e21f4831c6e58795462537f07f482 (patch)
treeac9bd5c7a0b9a78acea42ad48ab42b4192e2e1f5
parentfa406902d5a4bd3f50d29c3e3cff723e18492c2f (diff)
downloadphp-git-a3cb94abff0e21f4831c6e58795462537f07f482.tar.gz
Fixed bug #34982 (array_walk_recursive() modifies elements outside function scope)
-rwxr-xr-xext/standard/tests/array/bug34982.phpt40
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/standard/tests/array/bug34982.phpt b/ext/standard/tests/array/bug34982.phpt
new file mode 100755
index 0000000000..9de3408b0a
--- /dev/null
+++ b/ext/standard/tests/array/bug34982.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #34982 array_walk_recursive() modifies elements outside function scope
+--FILE--
+<?php
+$ar = array(
+ 'element 1',
+ array('subelement1')
+ );
+
+func($ar);
+print_r($ar);
+
+function func($a) {
+ array_walk_recursive($a, 'apply');
+ print_r($a);
+}
+
+function apply(&$input, $key) {
+ $input = 'changed';
+}
+?>
+--EXPECT--
+Array
+(
+ [0] => changed
+ [1] => Array
+ (
+ [0] => changed
+ )
+
+)
+Array
+(
+ [0] => element 1
+ [1] => Array
+ (
+ [0] => subelement1
+ )
+
+)