3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <root> <result> <node> <title> Some Title Name</title> <categories> <category> categor_one </category> <category> categor_two </category> </categories> </node> <node> <title> Some Title Name</title> <categories> <category> categor_one </category> <category> categor_tree </category> </categories> </node> </result> </root> XML; $products = array(); $product_data = array(); $xml = simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOCDATA); foreach ($xml->result->node as $node) { $product_data['title'] = (string)$node->title; foreach($node->categories as $category) { if (is_array($category)) { $product_data['category'] = implode('///', $category); continue; } $product_data['category'] = (array)$category->category; } $products[(string)$node->title][] = $product_data; } $xmlDoc = new DOMDocument('1.0', 'UTF-8'); $root = $xmlDoc->appendChild($xmlDoc->createElement("root")); foreach ($products as $key => $product) { $productA = $root->appendChild($xmlDoc->createElement('product')); $productA->appendChild($xmlDoc->createElement("title", $key)); for ($i = 0; $i < count($product); $i++) { $productA->appendChild($xmlDoc->createElement("category" . $i, implode("///", $product[$i]["category"]))); } } $xmlDoc->formatOutput = true; echo $xmlDoc->saveXML();

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.5.10.0090.00916.96
8.5.00.0130.00922.04
8.4.150.0030.00014.05
8.4.140.0130.01017.96
8.4.130.0120.01017.99
8.4.120.0060.00420.77
8.4.110.0100.01022.84
8.4.100.0120.00919.73
8.4.90.0100.01118.62
8.4.80.0060.00319.72
8.4.70.0110.01218.05
8.4.60.0150.01018.94
8.4.50.0050.00418.83
8.4.40.0070.01317.91
8.4.30.0120.00920.41
8.4.20.0130.00718.08
8.4.10.0150.00022.73
8.3.280.0130.00818.63
8.3.270.0120.00916.61
8.3.260.0090.00717.02
8.3.250.0090.00919.54
8.3.240.0130.00816.74
8.3.230.0050.00516.89
8.3.220.0030.00717.69
8.3.210.0120.00418.73
8.3.200.0070.00217.27
8.3.190.0040.00417.59
8.3.180.0040.00418.62
8.3.170.0110.00721.01
8.3.160.0060.01220.45
8.3.150.0130.00717.67
8.3.140.0070.01116.86
8.3.130.0030.00616.85
8.3.120.0060.00319.29
8.3.110.0040.00720.94
8.3.100.0080.00024.06
8.3.90.0040.00426.77
8.3.80.0060.00317.97
8.3.70.0060.00916.88
8.3.60.0150.00316.75
8.3.50.0160.00324.54
8.3.40.0160.00319.08
8.3.30.0040.01119.14
8.3.20.0120.00624.18
8.3.10.0080.00024.66
8.3.00.0080.00026.16
8.2.290.0120.00720.96
8.2.280.0080.01018.88
8.2.270.0140.00717.41
8.2.260.0120.00317.21
8.2.250.0040.00418.75
8.2.240.0030.00617.32
8.2.230.0090.00022.58
8.2.220.0030.00624.06
8.2.210.0040.00426.77
8.2.200.0040.00416.75
8.2.190.0200.00716.63
8.2.180.0130.00617.00
8.2.170.0090.00619.29
8.2.160.0110.00322.96
8.2.150.0000.00825.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00020.04
8.2.110.0040.00420.79
8.2.100.0000.01118.04
8.2.90.0000.00818.13
8.2.80.0040.00419.11
8.2.70.0040.00417.88
8.2.60.0000.00817.75
8.2.50.0030.00618.00
8.2.40.0070.00618.20
8.2.30.0070.00718.19
8.2.20.0030.00518.13
8.2.10.0040.00818.78
8.2.00.0090.00318.71
8.1.330.0110.00822.50
8.1.320.0130.00716.26
8.1.310.0040.01518.64
8.1.300.0050.00518.76
8.1.290.0100.00030.84
8.1.280.0120.00325.92
8.1.270.0090.00022.32
8.1.260.0030.00526.35
8.1.250.0050.00328.09
8.1.240.0030.00622.40
8.1.230.0080.00422.46
8.1.220.0050.00318.89
8.1.210.0000.00818.77
8.1.200.0000.00817.72
8.1.190.0030.00517.73
8.1.180.0040.00419.39
8.1.170.0060.00618.32
8.1.160.0070.00518.41
8.1.150.0080.00518.34
8.1.140.0040.00818.44
8.1.130.0100.00219.02
8.1.120.0070.00517.65
8.1.110.0130.00017.70
8.1.100.0050.00817.68
8.1.90.0070.00517.68
8.1.80.0070.00717.71
8.1.70.0100.00217.71
8.1.60.0090.00417.77
8.1.50.0100.00317.67
8.1.40.0080.00417.80
8.1.30.0070.00617.99
8.1.20.0100.00417.76
8.1.10.0070.00617.78
8.1.00.0120.00117.76
8.0.300.0000.00720.40
8.0.290.0040.00417.13
8.0.280.0070.00418.20
8.0.270.0110.00117.91
8.0.260.0060.00618.13
8.0.250.0090.00417.44
8.0.240.0070.00417.46
8.0.230.0080.00417.48
8.0.220.0060.00717.44
8.0.210.0080.00417.38
8.0.200.0110.00217.43
8.0.190.0060.00617.50
8.0.180.0090.00317.42
8.0.170.0080.00417.42
8.0.160.0080.00317.43
8.0.150.0060.00617.39
8.0.140.0090.00417.38
8.0.130.0070.00515.69
8.0.120.0110.00317.45
8.0.110.0070.00517.46
8.0.100.0080.00417.34
8.0.90.0090.00317.35
8.0.80.0090.00817.33
8.0.70.0080.00317.47
8.0.60.0100.00317.42
8.0.50.0050.00617.37
8.0.30.0090.00817.42
8.0.20.0080.01317.43
8.0.10.0060.00617.52
8.0.00.0100.01017.29
7.4.330.0090.00016.58
7.4.320.0070.00417.20
7.4.300.0090.00317.27
7.4.290.0070.00517.18
7.4.280.0090.00317.18
7.4.270.0070.00517.29
7.4.260.0080.00315.62
7.4.250.0020.00917.25
7.4.240.0060.00617.22
7.4.230.0100.00317.28
7.4.220.0080.00317.06
7.4.210.0070.00817.06
7.4.200.0050.00517.29
7.4.190.0150.00017.62
7.4.180.0100.00517.62
7.4.160.0140.00017.62
7.4.150.0110.00417.62
7.4.140.0130.00417.62
7.4.130.0080.00917.02
7.4.120.0110.00717.17
7.4.110.0090.00817.24
7.4.100.0130.00417.31
7.4.90.0070.01017.26
7.4.80.0140.00217.27
7.4.70.0120.00417.24
7.4.60.0100.00817.14
7.4.50.0080.00717.06
7.4.40.0120.00417.14
7.4.30.0080.01117.18
7.4.20.0130.00317.13
7.4.10.0070.00817.20
7.4.00.0080.00717.24
7.3.330.0080.00517.05
7.3.320.0090.00215.59
7.3.310.0050.00517.18
7.3.300.0070.00417.06
7.3.290.0100.00616.96
7.3.280.0090.00717.19
7.3.270.0120.00217.62
7.3.260.0060.01117.17
7.3.250.0110.00417.62
7.3.240.0150.00017.62
7.3.230.0120.00817.27
7.3.220.0120.00417.62
7.3.210.0090.00717.15
7.3.200.0100.00617.15
7.3.190.0060.01017.14
7.3.180.0110.00617.07
7.3.170.0110.00617.12
7.3.160.0100.00617.08
7.3.150.0160.00517.12
7.3.140.0090.00717.10
7.3.130.0070.00917.13
7.3.120.0100.00617.11
7.3.110.0100.00517.24
7.3.100.0060.01017.04
7.3.90.0140.00317.16
7.3.80.0100.00717.09
7.3.70.0130.00217.19
7.3.60.0100.00717.18
7.3.50.0130.00317.16
7.3.40.0090.00717.13
7.3.30.0080.00817.04
7.3.20.0070.01217.13
7.3.10.0150.00317.14
7.3.00.0220.00617.16
7.2.340.0070.00717.62
7.2.330.0100.00717.16
7.2.320.0160.00017.35
7.2.310.0060.00917.23
7.2.300.0150.00417.29
7.2.290.0060.01217.28
7.2.280.0120.00517.18
7.2.270.0090.00817.30
7.2.260.0150.00217.30
7.2.250.0090.00717.28
7.2.240.0120.00517.33
7.2.230.0140.00317.32
7.2.220.0070.01117.32
7.2.210.0090.00717.25
7.2.200.0120.00417.31
7.2.190.0120.00517.25
7.2.180.0130.00417.28
7.2.170.0080.00917.19
7.2.160.0080.00817.23
7.2.150.0150.00617.27
7.2.140.0110.00917.30
7.2.130.0120.00417.21
7.2.120.0090.00717.26
7.2.110.0150.00217.25
7.2.100.0110.00717.71
7.2.90.0090.00917.58
7.2.80.0090.00917.89
7.2.70.0060.01217.78
7.2.60.0100.00717.64
7.2.50.0110.00717.69
7.2.40.0120.00617.68
7.2.30.0090.01017.77
7.2.20.0130.00417.67
7.2.10.0210.01517.60
7.2.00.0060.01017.67

preferences:
34.64 ms | 403 KiB | 5 Q