xref: /PHP-7.0/ext/standard/tests/array/bug61730.phpt (revision 99076bc2)
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(4)
32int(8)
33Array
34(
35    [3] => 1
36    [7] => 1
37)
38