1--TEST--
2Foreach loop tests - removing properties before and after the current property during the loop.
3--FILE--
4<?php
5
6class C {
7	public $a = "Original a";
8	public $b = "Original b";
9	public $c = "Original c";
10	public $d = "Original d";
11	public $e = "Original e";
12}
13
14echo "\nRemoving properties before the current element from an iterated object.\n";
15$obj = new C;
16$count=0;
17foreach ($obj as $v) {
18	if ($v==$obj->a) {
19		unset($obj->c);
20	}
21	var_dump($v);
22	if (++$count>10) {
23		echo "Loop detected.\n";
24		break;
25	}
26}
27var_dump($obj);
28
29echo "\nRemoving properties before the current element from an iterated object.\n";
30$obj = new C;
31foreach ($obj as $v) {
32	if ($v==$obj->b) {
33		unset($obj->a);
34	}
35	var_dump($v);
36	if (++$count>10) {
37		echo "Loop detected.\n";
38		break;
39	}
40}
41var_dump($obj);
42
43
44?>
45--EXPECTF--
46
47Removing properties before the current element from an iterated object.
48string(10) "Original a"
49string(10) "Original b"
50string(10) "Original d"
51string(10) "Original e"
52object(C)#%d (4) {
53  ["a"]=>
54  string(10) "Original a"
55  ["b"]=>
56  string(10) "Original b"
57  ["d"]=>
58  string(10) "Original d"
59  ["e"]=>
60  string(10) "Original e"
61}
62
63Removing properties before the current element from an iterated object.
64string(10) "Original a"
65string(10) "Original b"
66string(10) "Original c"
67string(10) "Original d"
68string(10) "Original e"
69object(C)#%d (4) {
70  ["b"]=>
71  string(10) "Original b"
72  ["c"]=>
73  string(10) "Original c"
74  ["d"]=>
75  string(10) "Original d"
76  ["e"]=>
77  string(10) "Original e"
78}
79