3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data='<data> <seg id="A1"/> <seg id="A5"/> <seg id="A12"/> <seg id="A29"/> <seg id="A30"/> </data>'; $doc=new SimpleXMLElement($data); var_dump($doc); foreach($doc->seg as &$seg) { if($seg['id'] == 'A12') { unset($seg); } } var_dump($doc);
Output for git.master, git.master_jit, rfc.property-hooks
object(SimpleXMLElement)#1 (1) { ["seg"]=> array(5) { [0]=> object(SimpleXMLElement)#2 (1) { ["@attributes"]=> array(1) { ["id"]=> string(2) "A1" } } [1]=> object(SimpleXMLElement)#3 (1) { ["@attributes"]=> array(1) { ["id"]=> string(2) "A5" } } [2]=> object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(1) { ["id"]=> string(3) "A12" } } [3]=> object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(1) { ["id"]=> string(3) "A29" } } [4]=> object(SimpleXMLElement)#6 (1) { ["@attributes"]=> array(1) { ["id"]=> string(3) "A30" } } } } Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in /in/pZ9Bt:14 Stack trace: #0 {main} thrown in /in/pZ9Bt on line 14
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.21 ms | 402 KiB | 8 Q