3v4l.org

run code in 300+ PHP versions simultaneously
<?php $context = [ 'mes' => [ 'attributes' => [ 't' => 'AddEvent', 'id' => 'test_id', ], 'ev' => [ 'attributes' => [ 'evt' => 'packet20130828ki3si0', 'src' => 'NVV', 'st' => 'test', 'start' => '12423511247', 'stop' => '12423991978', 'addrtype' => 'MB', 'clntID' => '+380957700418', 'lg' => '', 'bank' => '', 'lang' => '', 'prior' => '', 'brnm' => '', 'extref' => '', 'intref' => '', 'extaddrtype' => '', 'extaddrid' => '', 'recall' => '', ], 'attr' => [ [ 'attributes' => [ 'code' => '1', 'val' => '11', ], ], [ 'attributes' => [ 'code' => '2', 'val' => '12', ], ], ], 'hist' => [ [ 'attributes' => [ 'st' => '', 'ch' => '', 'lg' => '', 'con' => '', 'com' => '', 'addrtype' => '', 'addrid' => '', 'dt' => '', 'contactId' => '', ], ], ], ], ], ]; class Conv { protected $res; protected $context; public function __construct(array $context) { if (count($context) != 1) { throw new Exception('Must be only one root element', 500); } $this->context = $context; $this->init(key($this->context)); } public function conv() { return $this->a2x(current($this->context), $this->res)->asXML(); } protected function init($root) { $this->res = new SimpleXMLElement("<{$root}/>"); } protected function addAttribs(array $attribs, SimpleXMLElement $node) { if (count($attribs)) { foreach ($attribs as $attrKey => $attrVal) { $node->addAttribute($attrKey, $attrVal); } } return $node; } protected function a2x(array $inner, SimpleXMLElement $node, $caption = 'item') { if (isset($inner['attributes'])) { $this->addAttribs($inner['attributes'], $node); unset($inner['attributes']); } if (count($inner)) { if ($this->isEnumeration($inner)) { foreach ($inner as $item) { $subNode = $node->addChild($caption); $this->a2x($value, $subNode); } } else { foreach ($inner as $key => $value) { $subNode = $node->addChild($key); $this->a2x($value, $subNode); } } } return $this->res; } protected function isEnumeration(array $items) { $keys = array_keys($items); foreach ($keys as $key) { if (!is_numeric($key)) { return false; } } return true; } } $a2x = new Conv($context); var_dump($a2x->conv()); //->asXML();

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).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.00618.91
8.3.50.0170.00722.17
8.3.40.0130.00319.09
8.3.30.0110.00419.15
8.3.20.0120.00619.20
8.3.10.0040.00421.24
8.3.00.0080.00023.90
8.2.180.0110.01116.88
8.2.170.0040.01122.96
8.2.160.0090.01220.51
8.2.150.0120.00324.18
8.2.140.0050.00324.66
8.2.130.0070.00026.16
8.2.120.0070.00021.05
8.2.110.0030.00620.77
8.2.100.0000.01218.03
8.2.90.0000.00819.54
8.2.80.0000.00918.18
8.2.70.0000.00817.88
8.2.60.0060.00318.29
8.2.50.0080.00018.07
8.2.40.0060.00318.41
8.2.30.0040.00419.64
8.2.20.0040.00418.03
8.2.10.0000.00918.05
8.2.00.0060.00717.95
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0030.00628.09
8.1.240.0040.00424.04
8.1.230.0110.00021.16
8.1.220.0080.00018.77
8.1.210.0000.00819.16
8.1.200.0030.00617.48
8.1.190.0000.00717.78
8.1.180.0060.00318.10
8.1.170.0060.00618.91
8.1.160.0000.00819.12
8.1.150.0070.00018.80
8.1.140.0030.00517.70
8.1.130.0040.00418.11
8.1.120.0070.00017.65
8.1.110.0000.00817.65
8.1.100.0080.00017.76
8.1.90.0000.00717.72
8.1.80.0000.00717.71
8.1.70.0030.00317.60
8.1.60.0090.00317.79
8.1.50.0000.00817.69
8.1.40.0030.00517.77
8.1.30.0080.00017.76
8.1.20.0000.00817.91
8.1.10.0000.00817.73
8.1.00.0000.00917.62
8.0.300.0030.00620.33
8.0.290.0040.00417.43
8.0.280.0040.00418.73
8.0.270.0040.00417.48
8.0.260.0030.00317.08
8.0.250.0050.00317.29
8.0.240.0000.00817.16
8.0.230.0050.00217.30
8.0.220.0000.00817.23
8.0.210.0070.00017.10
8.0.200.0040.00417.32
8.0.190.0060.00317.13
8.0.180.0050.00317.23
8.0.170.0040.00417.09
8.0.160.0000.00717.25
8.0.150.0000.00717.04
8.0.140.0000.00717.09
8.0.130.0000.00613.68
8.0.120.0040.00417.07
8.0.110.0000.00717.06
8.0.100.0040.00417.03
8.0.90.0030.00617.22
8.0.80.0040.01117.11
8.0.70.0040.00417.21
8.0.60.0040.00417.27
8.0.50.0040.00417.18
8.0.30.0110.00817.47
8.0.20.0090.00917.40
8.0.10.0000.00717.21
8.0.00.0120.01017.09
7.4.330.0000.00516.97
7.4.320.0000.00716.77
7.4.300.0000.00616.75
7.4.290.0000.00716.78
7.4.280.0030.00316.93
7.4.270.0030.00616.94
7.4.260.0050.00013.47
7.4.250.0080.00016.85
7.4.240.0000.00716.72
7.4.230.0040.00416.76
7.4.220.0130.01016.76
7.4.210.0070.00816.87
7.4.200.0000.00816.85
7.4.190.0030.00316.91
7.4.160.0210.00316.71
7.4.150.0110.00717.40
7.4.140.0090.00817.86
7.4.130.0100.00716.77
7.4.120.0080.01016.76
7.4.110.0140.00716.81
7.4.100.0090.00916.80
7.4.90.0090.00916.86
7.4.80.0040.01219.39
7.4.70.0120.00916.89
7.4.60.0060.01016.65
7.4.50.0060.00316.90
7.4.40.0110.00422.77
7.4.30.0110.00716.94
7.4.00.0040.01115.11
7.3.330.0060.00013.72
7.3.320.0000.00613.67
7.3.310.0000.00816.50
7.3.300.0000.00816.71
7.3.290.0070.01116.70
7.3.280.0070.00816.66
7.3.270.0140.00317.40
7.3.260.0100.01018.24
7.3.250.0100.01116.78
7.3.240.0110.00616.84
7.3.230.0120.00616.89
7.3.210.0080.00816.77
7.3.200.0100.01319.39
7.3.190.0090.00916.60
7.3.180.0100.00716.66
7.3.170.0100.00616.84
7.3.160.0090.01316.66
7.3.120.0030.01214.88
7.2.330.0180.00017.02
7.2.320.0030.01717.02
7.2.310.0000.02217.01
7.2.300.0090.00916.86
7.2.290.0090.00917.02
7.2.60.0030.00916.77
7.2.00.0030.00919.29
7.1.200.0040.00316.02
7.1.100.0030.00718.24
7.1.70.0000.00817.12
7.1.60.0090.01519.08
7.1.50.0200.00317.08
7.1.00.0000.04322.55
7.0.200.0000.00817.01
7.0.140.0100.06322.20
7.0.80.0700.07720.06
7.0.70.0430.08020.06
7.0.60.0570.08020.04
7.0.50.0770.07020.41
7.0.40.0070.06020.23
7.0.30.0100.08720.12
7.0.20.0170.07720.20
7.0.10.0200.07720.24
7.0.00.0130.07720.25
5.6.280.0030.07321.11
5.6.230.0030.06720.93
5.6.220.0130.07720.69
5.6.210.0100.06720.61
5.6.200.0100.08321.07
5.6.190.0130.07721.04
5.6.180.0070.08721.31
5.6.170.0070.06321.13
5.6.160.0130.07721.10
5.6.150.0100.05021.10
5.6.140.0030.05721.12
5.6.130.0100.07721.31
5.6.120.0100.06021.29
5.6.110.0030.04721.16
5.6.100.0030.08321.20
5.6.90.0200.07021.07
5.6.80.0170.06020.67
5.6.70.0030.06020.34
5.6.60.0070.07320.52
5.6.50.0070.08720.57
5.6.40.0100.05720.62
5.6.30.0000.06020.51
5.6.20.0000.07320.64
5.6.10.0130.06320.57
5.6.00.0130.07720.48
5.5.370.0000.08320.59
5.5.360.0100.08020.50
5.5.350.0030.06020.53
5.5.340.0070.06720.88
5.5.330.0130.08021.06
5.5.320.0100.08321.00
5.5.310.0070.08721.05
5.5.300.0100.05321.04
5.5.290.0170.07720.98
5.5.280.0130.06321.04
5.5.270.0130.06021.00
5.5.260.0100.04720.83
5.5.250.0070.04020.66
5.5.240.0030.05020.43
5.5.230.0070.07320.29
5.5.220.0100.05020.34
5.5.210.0070.04320.34
5.5.200.0070.07720.37
5.5.190.0030.04320.29
5.5.180.0070.05320.36
5.5.160.0070.06320.20
5.5.150.0070.05020.37
5.5.140.0030.08020.16
5.5.130.0130.07720.26
5.5.120.0030.07320.23
5.5.110.0170.07020.38
5.5.100.0100.07720.26
5.5.90.0100.08020.04
5.5.80.0100.07320.32
5.5.70.0070.08320.08
5.5.60.0030.08320.08
5.5.50.0130.07320.16
5.5.40.0130.07720.10
5.5.30.0100.06320.11
5.5.20.0130.07320.11
5.5.10.0070.08720.25
5.5.00.0100.07720.20
5.4.450.0130.07319.60
5.4.440.0130.04019.55
5.4.430.0130.07719.43
5.4.420.0030.08319.55
5.4.410.0030.08319.43
5.4.400.0100.07719.27
5.4.390.0100.07319.38
5.4.380.0100.06718.93
5.4.370.0000.04719.03
5.4.360.0000.07319.22
5.4.350.0030.05719.24
5.4.340.0000.05019.22
5.4.320.0100.07019.38
5.4.310.0100.04019.04
5.4.300.0100.04018.91
5.4.290.0070.07319.01
5.4.280.0070.08019.23
5.4.270.0130.06319.23
5.4.260.0000.08318.91
5.4.250.0100.06719.09
5.4.240.0070.07719.01
5.4.230.0070.06319.09
5.4.220.0100.07319.26
5.4.210.0030.08019.10
5.4.200.0200.06318.94
5.4.190.0100.06019.02
5.4.180.0030.07719.22
5.4.170.0100.06319.21
5.4.160.0170.03719.21
5.4.150.0170.06719.17
5.4.140.0200.06316.54
5.4.130.0130.06316.37
5.4.120.0130.07016.62
5.4.110.0170.06716.63
5.4.100.0070.07716.63
5.4.90.0070.06016.46
5.4.80.0100.07316.51
5.4.70.0030.04316.58
5.4.60.0070.05016.54
5.4.50.0100.06716.57
5.4.40.0100.05716.46
5.4.30.0030.06016.56
5.4.20.0030.05016.55
5.4.10.0170.06316.50
5.4.00.0070.07316.06
5.3.290.0100.07714.63
5.3.280.0130.07714.58
5.3.270.0070.05314.60
5.3.260.0130.04314.60
5.3.250.0030.05714.56
5.3.240.0070.08014.48
5.3.230.0030.05714.56
5.3.220.0030.05714.56
5.3.210.0100.07014.40
5.3.200.0130.06014.51
5.3.190.0030.04714.52
5.3.180.0000.07714.52
5.3.170.0070.07314.55
5.3.160.0100.05314.48
5.3.150.0070.07314.43
5.3.140.0070.06714.53
5.3.130.0030.07714.54
5.3.120.0030.05314.54
5.3.110.0070.04314.39
5.3.100.0100.07314.02
5.3.90.0100.06313.98
5.3.80.0030.08314.01
5.3.70.0070.05013.93
5.3.60.0070.07713.95
5.3.50.0070.07713.80
5.3.40.0100.07313.88
5.3.30.0070.07013.87
5.3.20.0070.07313.68
5.3.10.0170.06313.65
5.3.00.0070.05713.62
5.2.170.0100.04012.64
5.2.160.0100.03712.64
5.2.150.0000.04312.64
5.2.140.0030.05312.64
5.2.130.0070.04712.64
5.2.120.0070.06012.64
5.2.110.0000.06712.64
5.2.100.0070.06312.64
5.2.90.0030.06012.64
5.2.80.0030.04712.64
5.2.70.0000.05312.64
5.2.60.0100.06012.64
5.2.50.0000.05012.64
5.2.40.0070.06312.64
5.2.30.0030.06312.64
5.2.20.0070.04012.64
5.2.10.0030.06012.64
5.2.00.0000.07012.64
5.1.60.0000.03712.64
5.1.50.0070.04312.64
5.1.40.0000.05712.64
5.1.30.0130.04712.64
5.1.20.0030.05712.64
5.1.10.0070.03712.64
5.1.00.0130.03312.64
5.0.50.0030.04712.64
5.0.40.0000.03312.64
5.0.30.0000.06712.64
5.0.20.0070.03312.64
5.0.10.0000.03712.64
5.0.00.0030.06312.64
4.4.90.0000.03312.64
4.4.80.0070.03312.64
4.4.70.0000.04012.64
4.4.60.0030.02712.64
4.4.50.0000.01712.64
4.4.40.0000.02712.64
4.4.30.0000.03712.64
4.4.20.0000.03312.64
4.4.10.0100.02712.64
4.4.00.0070.05012.64
4.3.110.0030.03312.64
4.3.100.0070.03012.64
4.3.90.0030.03312.64
4.3.80.0170.04312.64
4.3.70.0000.02712.64
4.3.60.0030.03312.64
4.3.50.0070.03012.64
4.3.40.0030.05012.64
4.3.30.0070.03312.64
4.3.20.0000.02712.64
4.3.10.0030.03312.64
4.3.00.0030.02712.64

preferences:
55.66 ms | 400 KiB | 5 Q