xref: /PHP-5.3/ext/standard/tests/array/bug33940.phpt (revision 610c7fbe)
1--TEST--
2Bug #33940 (array_map() fails to pass by reference when called recursively)
3--INI--
4allow_call_time_pass_reference=1
5error_reporting=4095
6--FILE--
7<?php
8function ref_map(&$item) {
9    if(!is_array($item)) {
10        $item = 1;
11        return 2;
12    } else {
13        $ret = array_map('ref_map', &$item);
14        return $ret;
15    }
16}
17
18$a = array(array(0), 0);
19$ret = array_map('ref_map', $a);
20echo 'Array: '; print_r($a);
21echo 'Return: '; print_r($ret);
22$a = array(array(0), 0);
23$ret = array_map('ref_map', &$a);
24echo 'Array: '; print_r($a);
25echo 'Return: '; print_r($ret);
26?>
27--EXPECTF--
28Array: Array
29(
30    [0] => Array
31        (
32            [0] => 0
33        )
34
35    [1] => 0
36)
37Return: Array
38(
39    [0] => Array
40        (
41            [0] => 2
42        )
43
44    [1] => 2
45)
46Array: Array
47(
48    [0] => Array
49        (
50            [0] => 1
51        )
52
53    [1] => 1
54)
55Return: Array
56(
57    [0] => Array
58        (
59            [0] => 2
60        )
61
62    [1] => 2
63)
64