3v4l.org

run code in 300+ PHP versions simultaneously
<?php function applyHLToSiblings(DOMDocument $D){ $words[0] = "cart"; /* $words[1] = "car"; $words[2] = "cartel"; $words[3] = "art"; $words[4] = "drug"; $words[5] = "drugs"; $words[6] = "rug"; $words[7] = "rugs"; */ $ps = function($siblingsContainer, $searchString, $name) use($D){ foreach($siblingsContainer->getChildNodes() as $node){ if($node instanceof DOMText){ if(mb_strlen($node->textContent, "UTF-8") >= mb_strlen($searchString)){ $o = mb_strpos($node->textContent, $searchString); if($o !== false){ $before = mb_substr($node->textContent, 0, $o); $wrap = mb_substr($node->textContent, $o, mb_strlen($searchString, "UTF-8")); $after = mb_substr($node->textContent, $o); print_r($before); print_r($wrap); print_r($after); } } } } }; foreach($words as $name => $word) $ps($container->documentNode, $word, $name); } $x = new DOMDocument(); $x->loadXML("<data>drugs cartel</data>"); applyHLToSiblings($x);

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.70.0070.01018.54
8.3.60.0100.01018.93
8.3.50.0140.00822.17
8.3.40.0140.00719.21
8.3.30.0070.00719.09
8.3.20.0080.00020.35
8.3.10.0000.00823.66
8.3.00.0000.00819.63
8.2.190.0060.01616.88
8.2.180.0070.00716.88
8.2.170.0180.00022.96
8.2.160.0070.00720.56
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0080.00018.00
8.2.120.0000.00826.35
8.2.110.0030.00720.64
8.2.100.0060.00618.18
8.2.90.0050.00519.42
8.2.80.0030.00518.00
8.2.70.0080.00017.88
8.2.60.0060.00318.18
8.2.50.0000.01118.07
8.2.40.0030.00519.57
8.2.30.0050.00220.96
8.2.20.0030.00618.06
8.2.10.0060.00318.33
8.2.00.0050.00218.38
8.1.280.0120.00625.92
8.1.270.0080.00023.97
8.1.260.0070.00028.09
8.1.250.0040.01128.09
8.1.240.0000.00824.23
8.1.230.0060.00619.68
8.1.220.0000.01117.91
8.1.210.0050.00318.77
8.1.200.0000.00917.60
8.1.190.0030.00517.35
8.1.180.0040.00418.10
8.1.170.0040.00419.03
8.1.160.0070.00022.25
8.1.150.0000.00719.11
8.1.140.0050.00319.71
8.1.130.0000.00718.03
8.1.120.0030.00717.63
8.1.110.0000.00817.72
8.1.100.0000.00817.70
8.1.90.0040.00417.59
8.1.80.0030.00617.75
8.1.70.0000.00717.75
8.1.60.0030.00617.86
8.1.50.0040.00417.66
8.1.40.0000.00817.63
8.1.30.0080.00017.87
8.1.20.0040.00417.91
8.1.10.0040.00417.74
8.1.00.0030.00617.75
8.0.300.0050.00218.77
8.0.290.0070.00017.00
8.0.280.0070.00018.69
8.0.270.0070.00017.52
8.0.260.0000.00717.38
8.0.250.0070.00017.13
8.0.240.0000.00717.21
8.0.230.0020.00717.25
8.0.220.0030.00317.14
8.0.210.0000.00717.18
8.0.200.0030.00317.06
8.0.190.0030.00517.16
8.0.180.0050.00217.23
8.0.170.0000.00917.08
8.0.160.0040.00417.25
8.0.150.0000.00717.02
8.0.140.0030.00617.15
8.0.130.0040.00513.65
8.0.120.0080.00017.08
8.0.110.0000.00917.23
8.0.100.0040.00417.06
8.0.90.0030.00517.08
8.0.80.0090.00917.16
8.0.70.0040.00417.08
8.0.60.0020.00516.98
8.0.50.0040.00417.00
8.0.30.0060.01217.44
8.0.20.0160.00417.52
8.0.10.0060.00317.20
8.0.00.0150.00817.08
7.4.330.0000.00517.09
7.4.320.0000.00616.76
7.4.300.0000.00616.78
7.4.290.0000.00616.62
7.4.280.0000.00716.82
7.4.270.0040.00416.87
7.4.260.0000.00916.64
7.4.250.0040.00416.63
7.4.240.0030.00316.78
7.4.230.0000.00716.80
7.4.220.0040.01216.73
7.4.210.0080.00716.72
7.4.200.0000.00716.83
7.4.160.0160.00016.59
7.4.150.0070.01117.40
7.4.140.0150.00817.86
7.4.130.0120.00816.77
7.4.120.0140.00316.70
7.4.110.0090.01216.70
7.4.100.0030.01416.75
7.4.90.0000.01616.77
7.4.80.0120.00619.39
7.4.70.0070.01016.68
7.4.60.0060.00916.89
7.4.50.0000.01216.82
7.4.40.0100.00716.68
7.4.30.0070.01016.76
7.4.00.0090.00814.99
7.3.330.0050.00013.71
7.3.320.0040.00413.46
7.3.310.0070.00016.47
7.3.300.0000.00716.61
7.3.290.0000.00716.50
7.3.280.0050.01016.61
7.3.270.0120.00617.40
7.3.260.0080.00816.70
7.3.250.0060.01216.76
7.3.240.0110.00516.75
7.3.230.0090.00916.70
7.3.210.0080.00816.80
7.3.200.0060.00916.73
7.3.190.0090.01316.79
7.3.180.0060.01116.85
7.3.170.0110.00716.68
7.3.160.0030.01816.59
7.3.120.0090.00514.99
7.3.110.0030.01314.92
7.3.100.0110.00315.12
7.3.90.0090.00615.04
7.3.80.0040.00915.00
7.3.70.0090.00414.81
7.3.60.0110.00014.83
7.3.50.0030.00914.97
7.3.40.0050.00814.88
7.3.30.0050.00914.96
7.3.20.0040.00916.84
7.3.10.0080.00616.90
7.3.00.0100.00516.72
7.2.330.0070.01416.86
7.2.320.0110.01416.84
7.2.310.0110.00716.76
7.2.300.0160.00317.04
7.2.290.0090.01316.99
7.2.250.0100.01015.15
7.2.240.0110.00815.16
7.2.230.0090.00615.18
7.2.220.0050.00815.20
7.2.210.0070.00715.09
7.2.200.0010.00915.24
7.2.190.0090.00615.02
7.2.180.0070.00815.15
7.2.170.0050.00515.17
7.2.60.0030.01017.09
7.2.00.0050.00519.35
7.1.330.0060.00815.86
7.1.320.0030.01215.86
7.1.310.0060.00415.92
7.1.300.0040.00815.86
7.1.290.0040.00616.06
7.1.280.0050.00715.89
7.1.270.0040.00415.82
7.1.260.0060.00715.93
7.1.200.0240.00615.87
7.1.100.0060.00318.18
7.1.70.0050.00217.41
7.1.60.0130.01019.36
7.1.50.0060.01617.18
7.1.00.0070.08322.58
7.0.200.0040.00416.89
7.0.60.0070.07719.91
7.0.50.0070.05017.87
7.0.40.0030.04320.24
7.0.30.0230.04020.17
7.0.20.0300.03720.21
7.0.10.0030.09020.31
7.0.00.0070.05320.39
5.6.280.0000.03721.17
5.6.210.0070.04320.61
5.6.200.0200.07718.20
5.6.190.0170.07720.63
5.6.180.0500.07020.84
5.6.170.0430.04720.53
5.6.160.0100.05320.69
5.6.150.0030.04718.32
5.6.140.0070.08018.30
5.6.130.0070.08318.32
5.6.120.0000.04721.13
5.6.110.0070.07721.03
5.6.100.0130.07021.18
5.6.90.0130.04321.18
5.6.80.0030.04320.59
5.5.350.1430.02720.46
5.5.340.0000.04318.07
5.5.330.0170.06720.37
5.5.320.0070.08320.43
5.5.310.0200.04020.41
5.5.300.0070.08318.09
5.5.290.0030.05718.17
5.5.280.0100.08320.98
5.5.270.0030.04020.76
5.5.260.0170.06320.88
5.5.250.0030.05720.91
5.5.240.0230.07720.28

preferences:
31.83 ms | 401 KiB | 5 Q