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; protected $lastKey = 'item'; 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 tryToAddAttribs(array &$inner, SimpleXMLElement $node) { if (isset($inner['attributes'])) { $this->addAttribs($inner['attributes'], $node); unset($inner['attributes']); } return $node; } protected function addEnum(array $items, SimpleXMLElement $node, $caption) { if (count($items)) { foreach ($items as $item) { $subNode = $node->addChild($caption); $this->tryToAddAttribs($inner, $subNode); } } } protected function a2x(array $inner, SimpleXMLElement $node) { $this->tryToAddAttribs($inner, $node); if (count($inner)) { foreach ($inner as $key => $value) { if ($this->isEnumeration($value)) { foreach ($inner as $item) { $this->addEnum($item, $node, $this->lastKey); } } else { $this->lastKey = $key; $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.0180.00317.00
8.3.50.0120.01018.47
8.3.40.0070.00719.04
8.3.30.0120.00319.10
8.3.20.0040.00419.15
8.3.10.0060.00320.90
8.3.00.0060.00319.63
8.2.180.0170.00017.00
8.2.170.0040.01222.96
8.2.160.0070.01018.96
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00820.89
8.2.110.0030.00621.23
8.2.100.0090.00318.28
8.2.90.0090.00019.55
8.2.80.0040.00419.66
8.2.70.0040.00417.88
8.2.60.0040.00418.18
8.2.50.0030.00618.07
8.2.40.0040.00418.32
8.2.30.0090.00018.34
8.2.20.0060.00318.06
8.2.10.0030.00518.08
8.2.00.0000.00818.11
8.1.280.0060.00925.92
8.1.270.0080.00023.99
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0070.00322.72
8.1.230.0070.00721.20
8.1.220.0000.00817.80
8.1.210.0050.00519.28
8.1.200.0080.00317.60
8.1.190.0000.00917.91
8.1.180.0000.00818.10
8.1.170.0060.00319.27
8.1.160.0000.00719.15
8.1.150.0110.00018.84
8.1.140.0050.00217.66
8.1.130.0000.00718.11
8.1.120.0000.00717.81
8.1.110.0000.00717.62
8.1.100.0080.00017.78
8.1.90.0070.00017.78
8.1.80.0030.00517.80
8.1.70.0000.00717.73
8.1.60.0000.00817.94
8.1.50.0030.00517.81
8.1.40.0000.00817.80
8.1.30.0080.00017.96
8.1.20.0040.00417.97
8.1.10.0040.00417.71
8.1.00.0050.00317.86
8.0.300.0000.00720.18
8.0.290.0040.00417.25
8.0.280.0070.00018.71
8.0.270.0030.00317.53
8.0.260.0000.00717.10
8.0.250.0040.00417.26
8.0.240.0000.00717.20
8.0.230.0040.00417.16
8.0.220.0000.00717.15
8.0.210.0030.00617.09
8.0.200.0030.00317.32
8.0.190.0040.00417.20
8.0.180.0050.00317.14
8.0.170.0030.00617.19
8.0.160.0000.00817.29
8.0.150.0000.00917.29
8.0.140.0000.00717.21
8.0.130.0050.00013.55
8.0.120.0000.00817.14
8.0.110.0040.00417.28
8.0.100.0030.00617.10
8.0.90.0060.00317.19
8.0.80.0040.01417.21
8.0.70.0020.00517.23
8.0.60.0000.00717.03
8.0.50.0030.00517.24
8.0.30.0080.01117.55
8.0.20.0090.01117.36
8.0.10.0070.00017.34
8.0.00.0120.01217.03
7.4.330.0000.00513.20
7.4.320.0000.00616.87
7.4.300.0080.00016.83
7.4.290.0030.00316.78
7.4.280.0000.00716.79
7.4.270.0000.00816.75
7.4.260.0060.00013.48
7.4.250.0040.00416.65
7.4.240.0030.00316.66
7.4.230.0070.00016.66
7.4.220.0130.00716.64
7.4.210.0070.01416.88
7.4.200.0000.00716.88
7.4.190.0030.00317.01
7.4.160.0080.00816.89
7.4.150.0110.00716.90
7.4.140.0100.00716.84
7.4.130.0090.00916.81
7.4.120.0160.00316.82
7.4.110.0160.00316.85
7.4.100.0160.00616.95
7.4.90.0120.00616.81
7.4.80.0120.00616.93
7.4.70.0080.00816.77
7.4.60.0060.01216.76
7.4.50.0060.00016.71
7.4.40.0050.01016.72
7.4.30.0100.00716.99
7.4.10.0090.01015.16
7.4.00.0080.01015.10
7.3.330.0000.00613.76
7.3.320.0030.00313.63
7.3.310.0000.00716.59
7.3.300.0040.00416.63
7.3.290.0060.00916.67
7.3.280.0090.01016.69
7.3.270.0090.00916.85
7.3.260.0110.00716.68
7.3.250.0060.01816.91
7.3.240.0030.01316.72
7.3.230.0110.01016.61
7.3.210.0060.01216.72
7.3.200.0130.01119.39
7.3.190.0160.00716.89
7.3.180.0070.01016.66
7.3.170.0060.01216.70
7.3.160.0160.00016.91
7.3.130.0040.01314.94
7.3.120.0100.00714.89
7.3.110.0110.00815.00
7.3.100.0130.00114.97
7.3.90.0080.00514.88
7.3.80.0030.00914.92
7.3.70.0070.00815.02
7.3.60.0090.00514.98
7.3.50.0060.00714.90
7.3.40.0060.01014.93
7.3.30.0090.00514.90
7.3.20.0090.00416.71
7.3.10.0060.00916.83
7.3.00.0080.00816.70
7.2.330.0180.00016.73
7.2.320.0060.01217.04
7.2.310.0090.01516.64
7.2.300.0130.01017.03
7.2.290.0110.00716.83
7.2.260.0050.01215.09
7.2.250.0040.01515.11
7.2.240.0070.01115.14
7.2.230.0080.00715.10
7.2.220.0050.00815.00
7.2.210.0070.00715.26
7.2.200.0060.01015.09
7.2.190.0070.00715.23
7.2.180.0040.01015.40
7.2.170.0040.00915.25
7.2.160.0070.00715.27
7.2.150.0080.00717.02
7.2.140.0020.01017.09
7.2.130.0050.01217.10
7.2.120.0040.00917.05
7.2.110.0060.00917.17
7.2.100.0050.00816.96
7.2.90.0020.01117.08
7.2.80.0090.00717.06
7.2.70.0020.01717.10
7.2.60.0090.00717.00
7.2.50.0040.01117.16
7.2.40.0080.00916.96
7.2.30.0050.01217.00
7.2.20.0050.00817.13
7.2.10.0110.00417.02
7.2.00.0040.00817.77
7.1.330.0070.00915.86
7.1.320.0040.00815.88
7.1.310.0050.00716.05
7.1.300.0060.00515.79
7.1.290.0080.00415.94
7.1.280.0070.00715.87
7.1.270.0050.00415.79
7.1.260.0040.00815.85
7.1.250.0070.00715.89
7.1.240.0080.00815.90
7.1.230.0070.00515.91
7.1.220.0050.00815.99
7.1.210.0060.00815.88
7.1.200.0050.00415.93
7.1.190.0090.00615.83
7.1.180.0060.00615.84
7.1.170.0050.00915.84
7.1.160.0080.00615.80
7.1.150.0070.01015.78
7.1.140.0050.00815.85
7.1.130.0060.00615.81
7.1.120.0050.00715.87
7.1.110.0060.00615.85
7.1.100.0020.01116.71
7.1.90.0060.00615.80
7.1.80.0060.00515.73
7.1.70.0040.01116.24
7.1.60.0080.00716.97
7.1.50.0030.00916.07
7.1.40.0050.00815.97
7.1.30.0070.00815.88
7.1.20.0030.00815.87
7.1.10.0050.00815.96
7.1.00.0050.02718.04
7.0.330.0030.00915.46
7.0.320.0060.00915.59
7.0.310.0060.00515.30
7.0.300.0040.01015.48
7.0.290.0020.01415.43
7.0.280.0040.01015.50
7.0.270.0040.00815.61
7.0.260.0060.00815.60
7.0.250.0020.01315.56
7.0.240.0050.00815.76
7.0.230.0070.00515.61
7.0.220.0060.00615.53
7.0.210.0030.00815.53
7.0.200.0090.00315.95
7.0.190.0070.00215.42
7.0.180.0050.00715.37
7.0.170.0070.00815.68
7.0.160.0010.00915.63
7.0.150.0020.01015.52
7.0.140.0050.03017.84
7.0.130.0030.01015.50
7.0.120.0030.03217.74
7.0.110.0030.00715.54
7.0.100.0020.01015.51
7.0.90.0080.00315.44
7.0.80.0100.00115.49
7.0.70.0060.00615.53
7.0.60.0080.03217.03
7.0.50.0070.02016.27
7.0.40.0070.01715.73
7.0.30.0120.01815.78
7.0.20.0120.03215.66
7.0.10.0120.02815.80
7.0.00.0050.03415.72
5.6.400.0020.01314.83
5.6.390.0050.00814.64
5.6.380.0080.00614.72
5.6.370.0070.01014.63
5.6.360.0040.00814.48
5.6.350.0070.00914.54
5.6.340.0080.00814.33
5.6.330.0050.00814.67
5.6.320.0020.01214.60
5.6.310.0050.00814.62
5.6.300.0020.01114.51
5.6.290.0050.00714.85
5.6.280.0080.02716.84
5.6.270.0070.00614.46
5.6.260.0020.01314.62
5.6.250.0060.00514.58
5.6.240.0080.00614.52
5.6.230.0040.00814.51
5.6.220.0050.00914.51
5.6.210.0060.03116.47
5.6.200.0070.02815.76
5.6.190.0080.02916.47
5.6.180.0170.02716.75
5.6.170.0210.02616.57
5.6.160.0090.03516.61
5.6.150.0090.02915.67
5.6.140.0030.03415.90
5.6.130.0080.01815.95
5.6.120.0040.02716.82
5.6.110.0060.02916.77
5.6.100.0070.01716.81
5.6.90.0090.02416.81
5.6.80.0030.03216.63
5.6.70.0120.02216.68
5.6.60.0070.00614.60
5.6.50.0060.00814.58
5.6.40.0050.00714.32
5.6.30.0000.01014.68
5.6.20.0030.00814.62
5.6.10.0040.00714.69
5.6.00.0080.00314.48
5.5.380.0000.01114.64
5.5.370.0020.01414.59
5.5.360.0050.00914.46
5.5.350.0110.02916.49
5.5.340.0080.02615.88
5.5.330.0060.03216.56
5.5.320.0160.02716.63
5.5.310.0100.02016.39
5.5.300.0070.03015.73
5.5.290.0060.03215.79
5.5.280.0090.01616.67
5.5.270.0060.03216.61
5.5.260.0090.02816.81
5.5.250.0050.03016.67
5.5.240.0080.02316.36
5.5.230.0020.01114.46
5.5.220.0080.00514.49
5.5.210.0070.00514.54
5.5.200.0070.00314.41
5.5.190.0090.00414.35
5.5.180.0050.00614.48
5.5.170.0040.00514.56
5.5.160.0050.00914.64
5.5.150.0080.00314.55
5.5.140.0030.01014.34
5.5.130.0020.01014.57
5.5.120.0030.01214.46
5.5.110.0080.00514.42
5.5.100.0000.01214.35
5.5.90.0040.01114.68
5.5.80.0050.00814.55
5.5.70.0060.00714.59
5.5.60.0040.00714.55
5.5.50.0060.00514.41
5.5.40.0100.00314.77
5.5.30.0030.01214.38
5.5.20.0020.01114.63
5.5.10.0060.00414.29
5.5.00.0050.01014.27
5.4.450.0080.03114.46
5.4.440.0060.01714.39
5.4.430.0020.03114.52
5.4.420.0020.02814.34
5.4.410.0040.02814.44
5.4.400.0060.03014.37
5.4.390.0070.02714.15
5.4.380.0070.01514.29
5.4.370.0070.01414.31
5.4.360.0050.01814.29
5.4.350.0000.02414.38
5.4.340.0030.01714.25
5.4.330.0050.00511.85
5.4.320.0070.02814.29
5.4.310.0020.03314.35
5.4.300.0020.02214.30
5.4.290.0030.01814.30
5.4.280.0030.02014.34
5.4.270.0050.01514.30
5.4.260.0060.02714.42
5.4.250.0050.02214.18
5.4.240.0070.02814.30
5.4.230.0020.02114.34
5.4.220.0030.02014.20
5.4.210.0060.02714.15
5.4.200.0040.02114.26
5.4.190.0070.02614.24
5.4.180.0020.01914.25
5.4.170.0040.02314.23
5.4.160.0080.01814.24
5.4.150.0080.02114.13
5.4.140.0080.02613.52
5.4.130.0040.03113.43
5.4.120.0070.02413.36
5.4.110.0080.02413.37
5.4.100.0060.02513.38
5.4.90.0050.01713.49
5.4.80.0080.02713.43
5.4.70.0050.01713.47
5.4.60.0060.01813.43
5.4.50.0090.01213.38
5.4.40.0020.03013.38
5.4.30.0050.02413.44
5.4.20.0050.01813.37
5.4.10.0040.01913.43
5.4.00.0040.01613.28
5.3.290.0070.02012.64
5.3.280.0070.01612.60
5.3.270.0060.01812.61
5.3.260.0030.02512.62
5.3.250.0030.02512.61
5.3.240.0080.02312.56
5.3.230.0060.02012.61
5.3.220.0060.02712.59
5.3.210.0040.02712.56
5.3.200.0050.01812.58
5.3.190.0060.01712.60
5.3.180.0030.02712.63
5.3.170.0050.02912.60
5.3.160.0050.02512.61
5.3.150.0020.01612.60
5.3.140.0060.01912.60
5.3.130.0050.01512.58
5.3.120.0060.01812.55
5.3.110.0060.01812.60
5.3.100.0070.02412.44
5.3.90.0020.03112.42
5.3.80.0030.02812.38
5.3.70.0030.01712.42
5.3.60.0050.01912.36
5.3.50.0020.02212.42
5.3.40.0070.01712.39
5.3.30.0070.01512.43
5.3.20.0030.02112.31
5.3.10.0060.02012.31
5.3.00.0010.03012.30
5.2.170.0030.03011.16
5.2.160.0070.04711.13
5.2.150.0030.05011.15
5.2.140.0000.05310.99
5.2.130.0000.04011.18
5.2.120.0030.05711.10
5.2.110.0100.05711.03
5.2.100.0130.03011.04
5.2.90.0100.03011.09
5.2.80.0070.04710.94
5.2.70.0030.04310.98
5.2.60.0030.03311.03
5.2.50.0070.04010.91
5.2.40.0030.03010.96
5.2.30.0070.06010.85
5.2.20.0100.05310.89
5.2.10.0100.04710.75
5.2.00.0030.03710.72
5.1.60.0000.02710.05
5.1.50.0030.0239.97
5.1.40.0070.0439.99
5.1.30.0030.05310.34
5.1.20.0100.04310.39
5.1.10.0030.02710.02
5.1.00.0100.02710.09
5.0.50.0000.0238.57
5.0.40.0000.0408.38
5.0.30.0030.0308.19
5.0.20.0000.0278.18
5.0.10.0000.0278.23
5.0.00.0000.0478.17
4.4.90.0000.0237.04
4.4.80.0030.0137.04
4.4.70.0030.0337.04
4.4.60.0030.0337.04
4.4.50.0000.0207.04
4.4.40.0030.0237.04
4.4.30.0030.0307.04
4.4.20.0030.0337.04
4.4.10.0070.0137.04
4.4.00.0000.0537.04
4.3.110.0030.0177.04
4.3.100.0000.0237.04
4.3.90.0030.0277.04
4.3.80.0000.0307.04
4.3.70.0030.0137.04
4.3.60.0000.0437.04
4.3.50.0070.0307.04
4.3.40.0030.0507.04
4.3.30.0000.0377.04
4.3.20.0000.0377.04
4.3.10.0030.0137.04
4.3.00.0000.0407.04

preferences:
45.72 ms | 401 KiB | 5 Q