3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <translations> <translation id="title"> <english name="name1" ad="ad1">Hello there, how are you?</english> <italian name="name2" ad="ad2">Ciao, come stai?</italian> </translation> <translation id="text2"> <english name="name3" ad="ad4">222Hello there, how are you?</english> <italian name="name3" ad="ad4">222Ciao, come stai?</italian> </translation> <translation id="text3"> <english name="name5" ad="ad5">333Hello there, how are you?</english> <italian name="name6" ad="ad6">333Ciao, come stai?</italian> </translation> </translations>'; $xml = new SimpleXMLElement($xml); $xml = $xml->translation; //echo $xml->translation->english['ad'].PHP_EOL; //echo $xml->translation['id']->italian['name']; function translate($xml, $id, $lang) { foreach ($xml as $element) { if($element['id'] == $id) { return $element->children()['italian']; //foreach($element as $key => $val) { // echo $element['id']."{$key}: {$val}".PHP_EOL; //} } } } var_dump(translate($xml, 'text2', 'italian'));
Output for git.master, git.master_jit, rfc.property-hooks
NULL

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:
29.72 ms | 401 KiB | 8 Q