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($item, $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.0070.01317.00
8.3.50.0110.01217.77
8.3.40.0120.00318.94
8.3.30.0040.01119.04
8.3.20.0000.00819.05
8.3.10.0080.00018.98
8.3.00.0040.00419.63
8.2.180.0150.00018.68
8.2.170.0040.01222.96
8.2.160.0120.00321.43
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0030.00626.16
8.2.120.0000.00921.27
8.2.110.0100.00021.31
8.2.100.0070.00418.16
8.2.90.0030.00619.71
8.2.80.0040.00419.40
8.2.70.0040.00417.88
8.2.60.0030.00618.18
8.2.50.0040.00818.07
8.2.40.0000.00818.34
8.2.30.0070.00018.46
8.2.20.0090.00019.81
8.2.10.0050.00218.03
8.2.00.0000.00818.04
8.1.280.0100.01025.92
8.1.270.0050.00324.66
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0060.00324.09
8.1.230.0070.00321.09
8.1.220.0040.00418.04
8.1.210.0060.00319.09
8.1.200.0070.00317.60
8.1.190.0000.00817.76
8.1.180.0000.00818.10
8.1.170.0070.00319.16
8.1.160.0040.00419.15
8.1.150.0040.00418.92
8.1.140.0020.00517.79
8.1.130.0000.00718.11
8.1.120.0000.00717.65
8.1.110.0000.00717.80
8.1.100.0000.00717.79
8.1.90.0000.00717.65
8.1.80.0030.00517.65
8.1.70.0030.00317.64
8.1.60.0000.00917.92
8.1.50.0080.00017.78
8.1.40.0000.00817.87
8.1.30.0030.00517.89
8.1.20.0050.00317.97
8.1.10.0040.00417.91
8.1.00.0000.00817.71
8.0.300.0030.00620.28
8.0.290.0000.00717.13
8.0.280.0070.00018.70
8.0.270.0000.00817.57
8.0.260.0080.00017.16
8.0.250.0000.00817.20
8.0.240.0040.00417.21
8.0.230.0040.00217.35
8.0.220.0030.00317.18
8.0.210.0070.00017.25
8.0.200.0040.00417.32
8.0.190.0030.00617.32
8.0.180.0060.00617.24
8.0.170.0030.00617.08
8.0.160.0080.00017.30
8.0.150.0030.00617.14
8.0.140.0030.00617.12
8.0.130.0030.00313.69
8.0.120.0050.00217.25
8.0.110.0040.00417.30
8.0.100.0040.00417.30
8.0.90.0040.00417.21
8.0.80.0090.00917.37
8.0.70.0030.00517.08
8.0.60.0060.00317.09
8.0.50.0030.00517.35
8.0.30.0120.00617.53
8.0.20.0110.00817.50
8.0.10.0050.00517.31
8.0.00.0140.01017.10
7.4.330.0000.00513.20
7.4.320.0030.00316.88
7.4.300.0060.00016.75
7.4.290.0030.00316.81
7.4.280.0030.00616.86
7.4.270.0040.00417.04
7.4.260.0030.00313.51
7.4.250.0030.00616.95
7.4.240.0060.00116.78
7.4.230.0030.00316.61
7.4.220.0150.00916.95
7.4.210.0060.01216.84
7.4.200.0040.00416.91
7.4.190.0040.00416.75
7.4.160.0070.01016.96
7.4.150.0140.00316.79
7.4.140.0090.01316.88
7.4.130.0110.00916.84
7.4.120.0090.01016.94
7.4.110.0150.00316.86
7.4.100.0230.00016.80
7.4.90.0120.00616.89
7.4.80.0130.00316.86
7.4.70.0150.00416.84
7.4.60.0100.00716.69
7.4.50.0000.01316.84
7.4.40.0000.01116.70
7.4.30.0060.01216.94
7.4.00.0000.00915.17
7.3.330.0070.00013.42
7.3.320.0000.00513.74
7.3.310.0070.00016.54
7.3.300.0080.00016.51
7.3.290.0070.01316.67
7.3.280.0070.01116.68
7.3.270.0110.00816.77
7.3.260.0160.00617.05
7.3.250.0170.00516.78
7.3.240.0120.00617.00
7.3.230.0090.01116.91
7.3.210.0110.00616.78
7.3.200.0100.00719.39
7.3.190.0160.00316.79
7.3.180.0090.00916.94
7.3.170.0140.01017.05
7.3.160.0130.01016.71
7.3.120.0040.01114.99
7.2.330.0160.01016.83
7.2.320.0030.02017.19
7.2.310.0120.00917.09
7.2.300.0000.01717.07
7.2.290.0070.01016.93
7.2.60.0100.00717.25
7.2.00.0040.00719.34
7.1.200.0080.00815.83
7.1.100.0270.01218.36
7.1.70.0000.00817.41
7.1.60.0100.01619.40
7.1.50.0040.01817.21
7.1.00.0070.06322.53
7.0.200.0000.00716.98
7.0.140.0100.06322.20
7.0.120.0000.04722.13
7.0.60.0030.05320.05
7.0.50.0100.03318.07
7.0.40.0100.03317.88
7.0.30.0000.04317.93
7.0.20.0100.08017.93
7.0.10.0070.07717.80
7.0.00.0070.04017.80
5.6.280.0070.07321.21
5.6.210.0130.06020.70
5.6.200.0030.04318.29
5.6.190.0000.04318.36
5.6.180.0000.04318.42
5.6.170.0000.04318.27
5.6.160.0070.05718.38
5.6.150.0070.07018.43
5.6.140.0130.07318.25
5.6.130.0130.06718.24
5.6.120.0000.05318.24
5.6.110.0100.08318.37
5.6.100.0030.08318.32
5.6.90.0100.04018.25
5.6.80.0100.07717.81
5.6.70.0030.08017.76
5.6.60.0070.07717.72
5.6.50.0130.07317.79
5.6.40.0070.06017.77
5.6.30.0130.07717.57
5.6.20.0100.07317.73
5.6.10.0030.07317.73
5.6.00.0100.07317.75
5.5.350.0000.03720.59
5.5.340.0030.04018.00
5.5.330.0030.04018.20
5.5.320.0000.04018.11
5.5.310.0000.08318.21
5.5.300.0070.08318.11
5.5.290.0070.04718.04
5.5.280.0070.05718.05
5.5.270.0000.06018.10
5.5.260.0070.07318.02
5.5.250.0100.06018.00
5.5.240.0030.07017.42
5.5.230.0030.06317.58
5.5.220.0070.07017.57
5.5.210.0170.07017.48
5.5.200.0070.07717.52
5.5.190.0100.08017.50
5.5.180.0230.05717.43
5.5.160.0030.05717.38
5.5.150.0070.07317.45
5.5.140.0070.07717.51
5.5.130.0030.07317.55
5.5.120.0000.04317.55
5.5.110.0100.07017.50
5.5.100.0070.07717.43
5.5.90.0030.04017.31
5.5.80.0000.07317.27
5.5.70.0070.07017.45
5.5.60.0070.05017.30
5.5.50.0130.07317.23
5.5.40.0130.07017.40
5.5.30.0030.04017.23
5.5.20.0070.08017.35
5.5.10.0100.07717.37
5.5.00.0030.06717.39
5.4.450.0030.05319.52
5.4.440.0030.06319.35
5.4.430.0070.04319.53
5.4.420.0100.08019.38
5.4.410.0030.08319.49
5.4.400.0030.06319.35
5.4.390.0000.08719.17
5.4.380.0130.06718.96
5.4.370.0070.06719.17
5.4.360.0100.07719.34
5.4.350.0100.07319.23
5.4.340.0170.06719.29
5.4.320.0030.04719.19
5.4.310.0030.08019.03
5.4.300.0030.05719.23
5.4.290.0030.08319.18
5.4.280.0030.05319.27
5.4.270.0070.08319.12
5.4.260.0130.04319.26
5.4.250.0070.07719.25
5.4.240.0100.07319.21
5.4.230.0100.07019.02
5.4.220.0130.07019.21
5.4.210.0130.05319.12
5.4.200.0130.06319.10
5.4.190.0070.04319.22
5.4.180.0100.06719.25
5.4.170.0070.04719.25
5.4.160.0100.05019.01
5.4.150.0130.06719.04
5.4.140.0070.06316.70
5.4.130.0070.07016.66
5.4.120.0000.08016.70
5.4.110.0070.06016.77
5.4.100.0070.07016.77
5.4.90.0170.06016.61
5.4.80.0030.07316.52
5.4.70.0030.07016.74
5.4.60.0070.07016.42
5.4.50.0130.06016.51
5.4.40.0100.06316.61
5.4.30.0130.03316.54
5.4.20.0130.06316.48
5.4.10.0030.07716.50
5.4.00.0000.05015.86
5.3.290.0130.07014.53
5.3.280.0030.08014.57
5.3.270.0070.07714.60
5.3.260.0000.04314.42
5.3.250.0000.05314.53
5.3.240.0100.07014.59
5.3.230.0070.04714.57
5.3.220.0030.06714.40
5.3.210.0030.05314.54
5.3.200.0070.06314.54
5.3.190.0030.07014.48
5.3.180.0030.07714.54
5.3.170.0070.04014.50
5.3.160.0070.05314.50
5.3.150.0070.08014.52
5.3.140.0000.08314.63
5.3.130.0130.07014.54
5.3.120.0000.08014.52
5.3.110.0070.07014.37
5.3.100.0130.07013.99
5.3.90.0100.07014.01
5.3.80.0030.05013.87
5.3.70.0030.05013.77
5.3.60.0070.04013.99
5.3.50.0130.06713.73
5.3.40.0030.04013.89
5.3.30.0000.06013.82
5.3.20.0030.08013.78
5.3.10.0100.06713.60
5.3.00.0030.04713.41
5.2.170.0100.03711.12
5.2.160.0070.06011.09
5.2.150.0030.05010.98
5.2.140.0070.04711.12
5.2.130.0000.06711.09
5.2.120.0000.04711.07
5.2.110.0070.05311.11
5.2.100.0030.03711.06
5.2.90.0000.04311.24
5.2.80.0030.06310.91
5.2.70.0070.04010.91
5.2.60.0030.06011.04
5.2.50.0070.04310.91
5.2.40.0100.06010.93
5.2.30.0030.04710.97
5.2.20.0070.03710.74
5.2.10.0130.05310.84
5.2.00.0030.06010.56
5.1.60.0070.0309.94
5.1.50.0070.05310.04
5.1.40.0000.05010.00
5.1.30.0000.03710.26
5.1.20.0030.05310.41
5.1.10.0030.03710.04
5.1.00.0070.02310.04
5.0.50.0000.0338.69
5.0.40.0000.0478.34
5.0.30.0000.0708.25
5.0.20.0100.0338.28
5.0.10.0030.0408.23
5.0.00.0030.0638.14
4.4.90.0030.0337.87
4.4.80.0070.0307.87
4.4.70.0000.0207.87
4.4.60.0030.0207.87
4.4.50.0000.0377.87
4.4.40.0000.0307.87
4.4.30.0000.0277.87
4.4.20.0000.0237.87
4.4.10.0100.0237.87
4.4.00.0000.0337.87
4.3.110.0000.0407.87
4.3.100.0030.0237.87
4.3.90.0030.0377.87
4.3.80.0000.0507.87
4.3.70.0030.0337.87
4.3.60.0070.0237.87
4.3.50.0000.0377.87
4.3.40.0070.0477.87
4.3.30.0030.0377.87
4.3.20.0030.0337.87
4.3.10.0000.0377.87
4.3.00.0030.0207.87

preferences:
36.76 ms | 401 KiB | 5 Q