xref: /PHP-7.1/ext/standard/tests/array/bug61730.phpt (revision 11e05092)
1--TEST--
2Bug #61730 (Segfault from array_walk modifying an array passed by reference)
3--FILE--
4<?php
5$myArray = array_fill(0, 10, 1);
6
7array_walk(
8    $myArray,
9    function($value, $key) use ($myArray)
10    {
11        reset($myArray);
12    }
13);
14
15array_walk(
16    $myArray,
17    function($value, $key) use (&$myArray)
18    {
19        var_dump($key);
20        unset($myArray[$key]);
21        unset($myArray[$key+1]);
22        unset($myArray[$key+2]);
23    }
24);
25
26
27
28print_r($myArray);
29--EXPECT--
30int(0)
31int(3)
32int(6)
33int(9)
34Array
35(
36)
37