3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<products> <product> <categoryName>Kable i konwertery AV</categoryName> <brandName>Belkin</brandName> <productCode>AV10176bt1M-BLK</productCode> <productId>5616488</productId> <productFullName>Kabel Belkin Kabel HDMI Ultra HD High Speed 1m-AV10176bt1M-BLK</productFullName> <productEan>0745883767465</productEan> <productEuroPriceNetto>59.71</productEuroPriceNetto> <productFrontendPriceNetto>258.54</productFrontendPriceNetto> <productFastestSupplierQuantity>23</productFastestSupplierQuantity> <deliveryEstimatedDays>2</deliveryEstimatedDays> </product> <product> <categoryName>Telewizory</categoryName> <brandName>Sony</brandName> <productCode>KDL32WD757SAEP</productCode> <productId>1005662</productId> <productFullName>Telewizor Sony KDL-32WD757 SAEP</productFullName> <productEan></productEan> <productEuroPriceNetto>412.33</productEuroPriceNetto> <productFrontendPriceNetto>1785.38</productFrontendPriceNetto> <productFastestSupplierQuantity>11</productFastestSupplierQuantity> <deliveryEstimatedDays>6</deliveryEstimatedDays> </product> <product> <categoryName>Kuchnie i akcesoria</categoryName> <brandName>Brimarex</brandName> <productCode>1566287</productCode> <productId>885156</productId> <productFullName>Brimarex Drewniane owoce, Kiwi - 1566287</productFullName> <productEan></productEan> <productEuroPriceNetto>0.7</productEuroPriceNetto> <productFrontendPriceNetto>3.05</productFrontendPriceNetto> <productFastestSupplierQuantity>7</productFastestSupplierQuantity> <deliveryEstimatedDays>3</deliveryEstimatedDays> </product> </products>'; $reader = new XMLReader(); $reader->xml($xml); $count = 0; $this_value = ''; $products = array(); while($reader->read()) { switch ($reader->nodeType) { case XMLReader::ELEMENT: // deal with self-closing tags e.g. <productEan /> if ($reader->isEmptyElement) { ${$reader->name} = ''; $products[$count][$reader->name] = ''; } break; case XMLReader::TEXT: case XMLReader::CDATA: // save the value for storage when we get to the end of the element $this_value = $reader->value; break; case XMLReader::END_ELEMENT: if ($reader->name == 'product') { $count++; print_r(array($categoryName, $brandName, $productCode, $productId, $productFullName, $productEan, $productEuroPriceNetto, $productFrontendPriceNetto, $productFastestSupplierQuantity, $deliveryEstimatedDays)); } elseif ($reader->name != 'products') { ${$reader->name} = $this_value; $products[$count][$reader->name] = $this_value; // set this_value to a blank string to allow for empty tags $this_value = ''; } break; case XMLReader::WHITESPACE: case XMLReader::SIGNIFICANT_WHITESPACE: default: // nothing to do break; } } $reader->close(); print_r($products);

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.4.120.0110.01020.73
8.4.110.0120.00819.34
8.4.100.0100.00718.07
8.4.90.0120.00320.97
8.4.80.0140.00618.18
8.4.70.0110.00918.38
8.4.60.0090.01218.79
8.4.50.0090.01319.67
8.4.40.0160.00319.57
8.4.30.0100.00722.61
8.4.20.0080.00820.61
8.4.10.0140.00319.64
8.3.250.0140.00519.27
8.3.240.0050.00516.94
8.3.230.0120.00716.95
8.3.220.0140.00419.21
8.3.210.0140.00518.90
8.3.200.0030.00617.07
8.3.190.0080.00516.94
8.3.180.0130.00619.07
8.3.170.0110.00819.10
8.3.160.0100.01018.70
8.3.150.0160.00320.90
8.3.140.0000.00817.03
8.3.130.0050.00518.54
8.3.120.0030.00620.87
8.3.110.0060.00320.94
8.3.100.0060.00324.06
8.3.90.0040.00426.77
8.3.80.0060.00318.68
8.3.70.0000.01517.13
8.3.60.0110.01118.80
8.3.50.0190.01318.12
8.3.40.0150.00319.04
8.3.30.0040.01119.04
8.3.20.0040.00422.15
8.3.10.0080.00020.71
8.3.00.0090.00019.63
8.2.290.0100.01017.35
8.2.280.0120.00718.81
8.2.270.0160.00317.18
8.2.260.0040.01520.48
8.2.250.0050.00319.13
8.2.240.0070.00319.11
8.2.230.0050.00322.58
8.2.220.0150.00337.54
8.2.210.0050.00326.77
8.2.200.0000.00920.44
8.2.190.0160.00018.67
8.2.180.0110.00718.48
8.2.170.0070.00722.96
8.2.160.0070.00719.68
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00420.20
8.2.110.0060.00320.77
8.2.100.0040.00818.03
8.2.90.0030.00519.55
8.2.80.0040.00417.97
8.2.70.0080.00017.88
8.2.60.0040.00418.30
8.2.50.0060.00318.07
8.2.40.0000.00818.54
8.2.30.0020.00518.50
8.2.20.0060.00318.38
8.2.10.0040.00419.89
8.2.00.0020.00518.39
8.1.330.0110.00816.45
8.1.320.0100.01016.52
8.1.310.0030.00617.05
8.1.300.0060.00318.43
8.1.290.0040.00718.88
8.1.280.0110.00425.92
8.1.270.0000.00920.70
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00621.36
8.1.230.0070.00421.21
8.1.220.0000.00818.16
8.1.210.0050.00318.77
8.1.200.0030.00617.85
8.1.190.0050.00317.73
8.1.180.0000.00818.10
8.1.170.0080.00318.89
8.1.160.0030.00519.20
8.1.150.0050.00219.27
8.1.140.0040.00420.63
8.1.130.0000.00717.77
8.1.120.0090.00017.78
8.1.110.0040.00417.81
8.1.100.0000.00717.81
8.1.90.0040.00417.70
8.1.80.0000.00717.82
8.1.70.0040.00417.69
8.1.60.0040.00417.89
8.1.50.0050.00317.86
8.1.40.0080.00017.84
8.1.30.0030.00517.80
8.1.20.0000.00917.98
8.1.10.0060.00317.85
8.1.00.0050.00317.82
8.0.300.0000.00718.77
8.0.290.0070.00017.13
8.0.280.0070.00018.75
8.0.270.0000.00717.59
8.0.260.0030.00317.20
8.0.250.0000.00717.27
8.0.240.0020.00517.27
8.0.230.0000.00817.34
8.0.220.0060.00317.18
8.0.210.0030.00317.08
8.0.200.0000.00717.16
8.0.190.0090.00017.20
8.0.180.0030.00517.13
8.0.170.0000.00917.38
8.0.160.0070.00017.11
8.0.150.0040.00417.34
8.0.140.0000.00717.11
8.0.130.0030.00313.72
8.0.120.0070.00017.16
8.0.110.0050.00217.23
8.0.100.0040.00417.13
8.0.90.0000.00717.06
8.0.80.0030.01017.22
8.0.70.0050.00217.20
8.0.60.0000.00817.17
8.0.50.0030.00517.17
8.0.30.0070.01117.39
8.0.20.0070.01117.45
8.0.10.0000.00817.16
8.0.00.0090.01117.17
7.4.330.0000.00515.55
7.4.320.0030.00316.96
7.4.300.0060.00016.85
7.4.290.0040.00416.86
7.4.280.0000.00816.75
7.4.270.0000.00716.75
7.4.260.0000.00716.73
7.4.250.0070.00016.91
7.4.240.0000.00816.94
7.4.230.0030.00616.94
7.4.220.0000.00816.69
7.4.210.0070.01216.92
7.4.200.0070.00016.97
7.4.160.0070.01116.88
7.4.140.0090.01217.86
7.4.130.0090.00916.70
7.4.120.0110.00717.04
7.4.110.0090.00916.96
7.4.100.0120.01216.79
7.4.90.0120.00616.98
7.4.80.0130.01319.39
7.4.70.0090.00916.98
7.4.60.0070.01016.84
7.4.50.0040.00816.76
7.4.40.0110.01117.02
7.3.330.0000.00613.54
7.3.320.0030.00313.35
7.3.310.0000.00716.52
7.3.300.0000.00716.55
7.3.290.0070.00716.63
7.3.280.0070.01216.60
7.3.260.0100.00816.70
7.3.240.0120.00816.77
7.3.230.0070.01116.93
7.3.210.0060.01217.01
7.3.200.0130.00416.82
7.3.190.0100.00716.66
7.3.180.0120.00916.87
7.3.170.0050.01516.80
7.3.160.0130.00716.88
7.3.20.1070.00315.20
7.3.10.1110.00615.09
7.3.00.1470.00315.15
7.2.330.0160.00317.09
7.2.320.0060.01216.66
7.2.310.0130.00416.76
7.2.300.0060.01117.11
7.2.290.0130.00717.01
7.2.150.1170.00715.21
7.2.140.1880.00714.88
7.2.130.1450.00715.37
7.2.120.2030.00715.33
7.2.110.1260.01315.05
7.2.100.1720.01015.30
7.2.90.1040.00715.54
7.2.80.1000.01015.42
7.2.70.0960.00615.18
7.2.60.0980.01315.35
7.2.50.1010.00715.41
7.2.40.1270.00015.09
7.2.30.1080.00015.46
7.2.20.1200.00315.22
7.2.10.1290.01015.40
7.2.00.1510.01015.25
7.1.250.1840.00014.45

preferences:
28.83 ms | 403 KiB | 5 Q