xref: /PHP-8.2/ext/standard/tests/array/bug61730.phpt (revision 7aacc705)
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?>
30--EXPECT--
31int(0)
32int(3)
33int(6)
34int(9)
35Array
36(
37)
38