xref: /PHP-8.1/ext/standard/tests/array/bug69068.phpt (revision 11e05092)
1--TEST--
2Bug #69068: Exchanging array during array_walk -> memory errors
3--FILE--
4<?php
5
6$array = [1, 2, 3];
7array_walk($array, function($value, $key) {
8    var_dump($value);
9    if ($value == 2) {
10        $GLOBALS['array'] = [4, 5];
11    }
12});
13var_dump($array);
14
15?>
16--EXPECT--
17int(1)
18int(2)
19int(4)
20int(5)
21array(2) {
22  [0]=>
23  int(4)
24  [1]=>
25  int(5)
26}
27