1--TEST--
2Foreach loop tests - Removing the current element from an iterated object.
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 the current element from an iterated object.\n";
15$obj = new C;
16$count=0;
17foreach ($obj as $v) {
18	if ($v==$obj->b) {
19		unset($obj->b);
20	}
21	var_dump($v);
22	if (++$count>10) {
23		echo "Loop detected.\n";
24		break;
25	}
26}
27var_dump($obj);
28
29
30?>
31===DONE===
32--EXPECTF--
33Removing the current element from an iterated object.
34string(10) "Original a"
35string(10) "Original b"
36
37Notice: Undefined property: C::$b in %s on line %d
38string(10) "Original c"
39
40Notice: Undefined property: C::$b in %s on line %d
41string(10) "Original d"
42
43Notice: Undefined property: C::$b in %s on line %d
44string(10) "Original e"
45object(C)#%d (4) {
46  ["a"]=>
47  string(10) "Original a"
48  ["c"]=>
49  string(10) "Original c"
50  ["d"]=>
51  string(10) "Original d"
52  ["e"]=>
53  string(10) "Original e"
54}
55===DONE===