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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
--TEST--
Bug #68215 (Behavior of foreach has changed)
--FILE--
<?php
$arr = array(
'a' => array(
'a' => 'apple',
'b' => 'banana',
'c' => 'cranberry',
'd' => 'mango',
'e' => 'pineapple'
),
'b' => array(
'a' => 'apple',
'b' => 'banana',
'c' => 'cranberry',
'd' => 'mango',
'e' => 'pineapple'
),
'c' => 'cranberry',
'd' => 'mango',
'e' => 'pineapple'
);
function test(&$child, $entry)
{
$i = 1;
foreach ($child AS $key => $fruit)
{
if (!is_numeric($key))
{
$child[$i] = $fruit;
unset($child[$key]);
$i++;
}
}
}
$i = 1;
foreach ($arr AS $key => $fruit)
{
$arr[$i] = $fruit;
if (is_array($fruit))
{
test($arr[$i], $fruit);
}
unset($arr[$key]);
$i++;
}
var_dump($arr);
?>
--EXPECT--
array(5) {
[1]=>
array(5) {
[1]=>
string(5) "apple"
[2]=>
string(6) "banana"
[3]=>
string(9) "cranberry"
[4]=>
string(5) "mango"
[5]=>
string(9) "pineapple"
}
[2]=>
array(5) {
[1]=>
string(5) "apple"
[2]=>
string(6) "banana"
[3]=>
string(9) "cranberry"
[4]=>
string(5) "mango"
[5]=>
string(9) "pineapple"
}
[3]=>
string(9) "cranberry"
[4]=>
string(5) "mango"
[5]=>
string(9) "pineapple"
}
|