3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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) { $el = $element->children(); var_dump($el->children($lang, true)); //foreach($element as $key => $val) { // echo $element['id']."{$key}: {$val}".PHP_EOL; //} } } } var_dump(translate($xml, 'text2', 'italian'));
based on 2Tltv

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0140.00316.90
7.1.200.0040.01116.00
7.1.70.0000.00817.42
7.1.60.0080.01119.11
7.1.50.0110.01417.05
7.1.00.0100.07022.53
7.0.200.0000.00816.91
7.0.140.0000.07722.16
7.0.60.0200.07320.14
7.0.50.0030.08717.97
7.0.40.0000.09720.26
7.0.30.0600.05720.32
7.0.20.0300.08020.30
7.0.10.0200.07020.21
7.0.00.0000.05320.22
5.6.280.0100.06721.00
5.6.210.0130.07720.71
5.6.200.0170.07718.29
5.6.190.0100.08320.58
5.6.180.0230.03720.54
5.6.170.0270.08720.67
5.6.160.0070.08320.58
5.6.150.0100.07318.38
5.6.140.0130.07318.40
5.6.130.0070.04718.35
5.6.120.0100.08021.05
5.6.110.0030.08321.19
5.6.100.0130.06321.03
5.6.90.0030.07720.99
5.6.80.0130.06720.40
5.6.70.4430.04020.40
5.5.350.0170.08320.55
5.5.340.0100.04018.11
5.5.330.0070.04320.43
5.5.320.0230.04320.43
5.5.310.0270.06720.41
5.5.300.0030.05018.05
5.5.290.0030.04018.16
5.5.280.0070.04721.01
5.5.270.0030.06320.88
5.5.260.0100.08020.84
5.5.250.0200.06720.68
5.5.240.0200.08020.45
5.4.450.0800.05719.69
5.4.440.0830.06319.50
5.4.430.0800.06019.76
5.4.420.0770.05319.54
5.4.410.0170.05319.23
5.4.400.1070.06719.36
5.4.390.0370.05019.01
5.4.380.0770.04719.39
5.4.370.0900.06319.04
5.4.360.0800.05319.47
5.4.350.0900.08319.20
5.4.340.0060.03412.17
5.4.320.0030.03812.66
5.4.310.0060.03812.66
5.4.300.0060.04012.66
5.4.290.0050.03812.66
5.4.280.0080.03512.55
5.4.270.0080.03412.55
5.4.260.0050.03912.56
5.4.250.0070.03812.55
5.4.240.0060.04412.55
5.4.230.0060.04312.54
5.4.220.0050.03512.55
5.4.210.0050.03612.54
5.4.200.0050.03812.55
5.4.190.0050.03512.54
5.4.180.0060.03512.54
5.4.170.0030.04812.56
5.4.160.0070.03312.55
5.4.150.0070.03612.55
5.4.140.0050.03712.23
5.4.130.0050.04212.22
5.4.120.0030.03612.18
5.4.110.0070.04012.17
5.4.100.0030.03712.18
5.4.90.0050.03612.18
5.4.80.0040.03712.17
5.4.70.0080.03112.17
5.4.60.0080.03312.17
5.4.50.0060.03512.17
5.4.40.0050.03512.16
5.4.30.0060.03412.15
5.4.20.0050.03512.15
5.4.10.0030.03712.15
5.4.00.0020.03911.64
5.3.290.0070.04012.92
5.3.280.0070.04412.86
5.3.270.0080.04112.87
5.3.260.0050.03912.86
5.3.250.0090.03612.87
5.3.240.0050.03612.87
5.3.230.0060.03812.86
5.3.220.0030.03912.82
5.3.210.0070.03812.83
5.3.200.0040.04012.82
5.3.190.0030.03912.83
5.3.180.0100.03712.82
5.3.170.0050.03712.83
5.3.160.0070.04012.82
5.3.150.0060.03612.82
5.3.140.0040.03712.81
5.3.130.0090.03412.80
5.3.120.0040.04012.81
5.3.110.0050.04012.80
5.3.100.0080.03412.30
5.3.90.0070.03512.28
5.3.80.0070.03412.26
5.3.70.0040.03812.26
5.3.60.0100.03212.25
5.3.50.0030.03812.20
5.3.40.0060.03612.20
5.3.30.0050.03512.15
5.3.20.0040.03911.94
5.3.10.0040.03611.91
5.3.00.0030.03811.89
5.2.170.0050.0299.40
5.2.160.0030.0309.40
5.2.150.0080.0309.40
5.2.140.0040.0309.39
5.2.130.0050.0279.36
5.2.120.0020.0319.36
5.2.110.0060.0279.36
5.2.100.0070.0259.36
5.2.90.0030.0299.35
5.2.80.0050.0309.34
5.2.70.0070.0419.34
5.2.60.0040.0319.30
5.2.50.0020.0329.28
5.2.40.0070.0319.25
5.2.30.0070.0269.22
5.2.20.0060.0319.21
5.2.10.0030.0289.12
5.2.00.0050.0288.97
5.1.60.0040.0238.26
5.1.50.0050.0238.25
5.1.40.0030.0258.23
5.1.30.0030.0318.59
5.1.20.0080.0248.61
5.1.10.0070.0258.32
5.1.00.0060.0278.33
5.0.50.0030.0206.81
5.0.40.0050.0186.67
5.0.30.0040.0356.49
5.0.20.0030.0196.45
5.0.10.0040.0196.43
5.0.00.0070.0266.43
4.4.90.0020.0154.78
4.4.80.0030.0144.75
4.4.70.0030.0234.75
4.4.60.0030.0144.76
4.4.50.0040.0214.77
4.4.40.0070.0264.71
4.4.30.0020.0154.76
4.4.20.0040.0224.84
4.4.10.0040.0134.85
4.4.00.0010.0254.76
4.3.110.0050.0194.67
4.3.100.0030.0154.66
4.3.90.0020.0214.64
4.3.80.0010.0264.59
4.3.70.0000.0174.63
4.3.60.0030.0144.63
4.3.50.0010.0244.63
4.3.40.0060.0334.53
4.3.30.0020.0153.31
4.3.20.0030.0153.28
4.3.10.0040.0213.24
4.3.00.0270.0236.92