blob: 485b9d8bc4a0ffe51324bd1f66ad368c49dad25b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
--TEST--
Bug #75717: RecursiveArrayIterator does not traverse arrays by reference
--FILE--
<?php
function flatten(array $nestedArraysAndStrings){
$flat=[];
$iter = new RecursiveIteratorIterator(
new RecursiveArrayIterator($nestedArraysAndStrings));
foreach($iter as $leaf){ $flat[] = $leaf; }
return join(NULL, $flat);
}
$noRefs = [[[['some']]],[' nested '],"items"];
$withRefs = []+$noRefs;
$wat = $noRefs[0];
$withRefs[0] = &$wat;
echo flatten($noRefs), "\n";
echo flatten($withRefs), "\n";
?>
--EXPECT--
some nested items
some nested items
|