summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-10-15 17:02:54 +0400
committerDmitry Stogov <dmitry@zend.com>2014-10-15 17:02:54 +0400
commited18d67c5e69e4b5713e940568e5b3d0a7392a8d (patch)
tree2addfd6288ff387d0b6c3afb03f226a76cd2bc63 /Zend/tests
parentc32614370f1c819e5f2bb632912b4fcc6092cbfb (diff)
downloadphp-git-ed18d67c5e69e4b5713e940568e5b3d0a7392a8d.tar.gz
Fixed bug #68215 (Behavior of foreach has changed)
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/bug68215.phpt91
1 files changed, 91 insertions, 0 deletions
diff --git a/Zend/tests/bug68215.phpt b/Zend/tests/bug68215.phpt
new file mode 100644
index 0000000000..c4e8da8515
--- /dev/null
+++ b/Zend/tests/bug68215.phpt
@@ -0,0 +1,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"
+}