3v4l.org

run code in 300+ PHP versions simultaneously
<?php // http://www.webgeekly.com/tutorials/jquery/how-to-make-your-site-multilingual-using-xml-and-jquery/ $xml = ' <?xml version="1.0" encoding="UTF-8"?> <translations> <translation id="id1"> <es>Españo11</es> <en>English1</en> </translation> <translation id="id2"> <es>Españo12</es> <en>English2</en> </translation> <translation id="id3"> <es>Españo13</es> <en>English13</en> </translation> </translations>'; $xml = new SimpleXMLElement($xml); $xml = $xml->translation; function translate($xml, $id, $lang) { foreach ($xml as $element) { if($element['id'] == $id) { return $element->{$lang}; } } } echo translate($xml, 'id1', 'es'); echo translate($xml, 'id1', 'en'); echo translate($xml, 'id2', 'es'); echo translate($xml, 'id2', 'en'); echo translate($xml, 'id3', 'es'); echo translate($xml, 'id3', 'en');
Output for git.master, git.master_jit, rfc.property-hooks
Warning: SimpleXMLElement::__construct(): Entity: line 2: parser error : XML declaration allowed only at the start of the document in /in/4vCbh on line 22 Warning: SimpleXMLElement::__construct(): <?xml version="1.0" encoding="UTF-8"?> in /in/4vCbh on line 22 Warning: SimpleXMLElement::__construct(): ^ in /in/4vCbh on line 22 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/4vCbh:22 Stack trace: #0 /in/4vCbh(22): SimpleXMLElement->__construct('\n<?xml version=...') #1 {main} thrown in /in/4vCbh on line 22
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:
51.04 ms | 402 KiB | 8 Q