~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/standard/tests/array/bug34982.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

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