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($D->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.60.0000.01418.43
8.3.50.0170.00318.16
8.3.40.0070.00719.09
8.3.30.0130.01019.15
8.3.20.0040.00420.59
8.3.10.0070.00023.86
8.3.00.0050.00319.63
8.2.180.0040.01116.75
8.2.170.0090.00922.96
8.2.160.0150.00620.64
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00617.88
8.2.120.0040.00426.35
8.2.110.0100.00021.07
8.2.100.0080.00418.09
8.2.90.0000.00819.47
8.2.80.0060.00317.97
8.2.70.0000.00917.88
8.2.60.0080.00018.05
8.2.50.0030.00618.07
8.2.40.0040.00419.41
8.2.30.0000.00820.87
8.2.20.0030.00618.01
8.2.10.0050.00218.32
8.2.00.0040.00418.32
8.1.280.0040.01125.92
8.1.270.0050.00324.03
8.1.260.0050.00328.09
8.1.250.0110.00428.09
8.1.240.0060.00319.53
8.1.230.0090.00317.52
8.1.220.0000.00817.90
8.1.210.0050.00318.77
8.1.200.0000.00917.48
8.1.190.0000.00817.47
8.1.180.0000.00818.10
8.1.170.0000.00820.63
8.1.160.0050.00322.24
8.1.150.0000.00719.14
8.1.140.0000.00819.71
8.1.130.0030.00617.94
8.1.120.0000.01017.73
8.1.110.0000.00717.58
8.1.100.0040.00417.61
8.1.90.0000.00717.71
8.1.80.0000.00817.61
8.1.70.0030.00317.60
8.1.60.0040.00417.74
8.1.50.0000.00817.70
8.1.40.0080.00017.61
8.1.30.0050.00317.70
8.1.20.0040.00417.73
8.1.10.0080.00017.71
8.1.00.0080.00417.68
8.0.300.0000.00718.77
8.0.290.0000.00717.00
8.0.280.0080.00018.66
8.0.270.0070.00017.49
8.0.260.0080.00017.55
8.0.250.0000.00817.24
8.0.240.0040.00417.12
8.0.230.0030.00717.15
8.0.220.0000.00717.25
8.0.210.0040.00417.11
8.0.200.0070.00017.27
8.0.190.0000.01017.29
8.0.180.0080.00017.07
8.0.170.0000.00917.21
8.0.160.0000.00817.06
8.0.150.0000.00717.08
8.0.140.0030.00817.03
8.0.130.0060.00313.57
8.0.120.0040.00417.09
8.0.110.0090.00017.20
8.0.100.0000.00717.19
8.0.90.0040.00417.08
8.0.80.0090.00617.22
8.0.70.0040.00417.18
8.0.60.0000.00817.20
8.0.50.0000.00816.98
8.0.30.0120.00817.44
8.0.20.0100.01017.40
8.0.10.0040.00417.27
8.0.00.0080.01017.11
7.4.330.0020.00216.98
7.4.320.0000.00616.81
7.4.300.0060.00016.64
7.4.290.0030.00316.77
7.4.280.0000.00816.82
7.4.270.0030.00516.79
7.4.260.0040.00416.83
7.4.250.0040.00416.63
7.4.240.0060.00316.82
7.4.230.0000.00816.91
7.4.220.0090.00916.72
7.4.210.0100.00716.77
7.4.200.0000.00816.73
7.4.150.0080.00917.40
7.4.140.0080.01517.86
7.4.130.0100.01216.76
7.4.120.0080.00916.75
7.4.110.0090.01116.75
7.4.100.0120.00616.84
7.4.90.0060.01316.86
7.4.80.0120.00619.39
7.4.70.0130.00316.77
7.4.60.0090.00616.98
7.4.50.0120.00316.88
7.4.40.0140.00316.86
7.4.30.0070.01016.64
7.4.00.0090.00615.17
7.3.330.0020.00213.47
7.3.320.0080.00013.45
7.3.310.0040.00416.44
7.3.300.0070.00016.62
7.3.290.0040.00416.50
7.3.280.0050.01316.64
7.3.270.0140.00717.40
7.3.260.0140.00316.73
7.3.250.0080.01116.61
7.3.240.0030.01316.70
7.3.230.0060.01216.57
7.3.210.0160.00016.55
7.3.200.0120.00316.75
7.3.190.0070.01516.70
7.3.180.0180.00616.57
7.3.170.0130.00316.63
7.3.160.0060.01216.74
7.3.10.0100.00316.80
7.3.00.0030.00716.71
7.2.330.0150.00416.77
7.2.320.0030.01416.96
7.2.310.0090.00916.91
7.2.300.0130.00516.99
7.2.290.0030.01416.77
7.2.130.0040.00816.94
7.2.120.0070.00716.94
7.2.110.0120.00316.78
7.2.100.0060.00917.01
7.2.90.0090.00617.09
7.2.80.0060.01016.94
7.2.70.0030.00917.20
7.2.60.0430.01116.09
7.2.50.0070.01016.98
7.2.40.0030.01217.02
7.2.30.0070.00716.98
7.2.20.0040.01517.06
7.2.10.0030.01216.75
7.2.00.0050.00718.22
7.1.250.0060.00616.07
7.1.200.0040.00816.01
7.1.100.0040.00718.31
7.1.70.0080.00017.29
7.1.60.0090.01619.36
7.1.50.0090.01317.19
7.1.00.0000.08022.64
7.0.200.0030.00316.66
7.0.60.0130.07320.00
7.0.50.0200.07017.95
7.0.40.0130.06320.33
7.0.30.0270.05320.32
7.0.20.0330.07720.24
7.0.10.0070.09020.29
7.0.00.0070.05720.30
5.6.280.0000.03321.05
5.6.210.0070.08320.52
5.6.200.0030.07718.36
5.6.190.0070.08720.81
5.6.180.0400.04320.78
5.6.170.0230.05720.64
5.6.160.0030.04720.62
5.6.150.0030.06718.22
5.6.140.0100.04018.30
5.6.130.0070.08718.28
5.6.120.0130.07021.16
5.6.110.0170.07321.00
5.6.100.0070.04021.19
5.6.90.0200.07021.12
5.6.80.0130.03020.52
5.5.350.3870.03720.45
5.5.340.0070.07718.03
5.5.330.0070.08720.58
5.5.320.0100.08320.48
5.5.310.0270.03320.41
5.5.300.0130.06718.20
5.5.290.0070.04018.15
5.5.280.0030.04721.06
5.5.270.0030.04720.79
5.5.260.0130.04020.81
5.5.250.0100.08020.74
5.5.240.0200.08020.32

preferences:
45.01 ms | 400 KiB | 5 Q