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->childNodes 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){ $l = mb_strlen($searchString, "UTF-8"); $before = mb_substr($node->textContent, 0, $o); $wrap = mb_substr($node->textContent, $o, $l); $after = mb_substr($node->textContent, $o + $l); var_dump($before); var_dump($wrap); var_dump($after); } } } } }; foreach($words as $name => $word) $ps($D->documentElement, $word, $name); } $x = new DOMDocument(); $x->loadXML("<data>drugs cartel</data>"); applyHLToSiblings($x); var_dump($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.0090.00616.50
8.3.60.0090.00618.43
8.3.50.0170.00522.05
8.3.40.0040.01219.04
8.3.30.0160.00319.09
8.3.20.0040.00420.41
8.3.10.0040.00423.78
8.3.00.0060.00319.38
8.2.190.0160.00617.13
8.2.180.0100.00617.13
8.2.170.0120.00422.96
8.2.160.0070.00720.78
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00917.88
8.2.120.0040.00426.35
8.2.110.0030.00720.60
8.2.100.0100.00318.28
8.2.90.0080.00019.45
8.2.80.0030.00517.97
8.2.70.0060.00317.63
8.2.60.0030.00618.29
8.2.50.0000.01018.07
8.2.40.0040.00419.59
8.2.30.0000.00720.85
8.2.20.0040.00418.05
8.2.10.0020.00518.38
8.2.00.0000.00918.32
8.1.280.0160.00325.92
8.1.270.0100.00024.13
8.1.260.0040.00428.09
8.1.250.0110.00428.09
8.1.240.0030.00624.17
8.1.230.0090.00319.67
8.1.220.0060.00517.79
8.1.210.0060.00318.77
8.1.200.0040.00417.60
8.1.190.0000.00917.50
8.1.180.0000.00818.10
8.1.170.0000.00818.89
8.1.160.0000.00822.18
8.1.150.0040.00419.19
8.1.140.0000.00819.72
8.1.130.0000.00717.89
8.1.120.0060.00317.61
8.1.110.0030.00517.67
8.1.100.0030.00617.76
8.1.90.0070.00017.61
8.1.80.0000.00817.72
8.1.70.0000.00717.55
8.1.60.0000.00817.94
8.1.50.0040.00417.88
8.1.40.0040.00417.84
8.1.30.0060.00317.79
8.1.20.0040.00417.74
8.1.10.0030.00517.75
8.1.00.0100.00017.85
8.0.300.0050.00318.77
8.0.290.0070.00017.25
8.0.280.0030.00518.76
8.0.270.0040.00417.46
8.0.260.0000.00817.55
8.0.250.0000.00717.37
8.0.240.0000.00717.21
8.0.230.0040.00717.27
8.0.220.0070.00017.16
8.0.210.0040.00417.15
8.0.200.0000.00817.38
8.0.190.0080.00017.33
8.0.180.0000.00717.27
8.0.170.0070.00017.30
8.0.160.0080.00017.35
8.0.150.0000.00717.30
8.0.140.0030.00917.25
8.0.130.0090.00013.76
8.0.120.0060.00317.28
8.0.110.0050.00317.13
8.0.100.0000.00717.16
8.0.90.0000.00717.21
8.0.80.0110.00417.21
8.0.70.0030.00517.11
8.0.60.0080.00017.11
8.0.50.0040.00417.14
8.0.30.0060.01317.30
8.0.20.0130.01017.44
8.0.10.0000.00717.34
8.0.00.0130.01116.90
7.4.330.0050.00016.86
7.4.320.0000.00616.90
7.4.300.0030.00316.75
7.4.290.0070.00016.82
7.4.280.0000.00716.79
7.4.270.0030.00316.83
7.4.260.0040.00416.83
7.4.250.0040.00416.77
7.4.240.0020.00516.70
7.4.230.0000.00716.82
7.4.220.0200.00916.85
7.4.210.0020.01616.80
7.4.200.0040.00416.77
7.4.160.0090.00916.78
7.4.150.0030.01717.40
7.4.140.0110.01417.86
7.4.130.0110.00916.77
7.4.120.0090.01316.72
7.4.110.0100.01016.83
7.4.100.0160.01016.71
7.4.90.0130.00916.82
7.4.80.0170.00319.39
7.4.70.0070.01316.66
7.4.60.0120.00616.80
7.4.50.0030.01316.75
7.4.40.0090.01216.86
7.4.30.0180.00616.58
7.4.00.0040.01115.10
7.3.330.0050.00013.65
7.3.320.0000.00613.56
7.3.310.0000.00716.66
7.3.300.0070.00016.52
7.3.290.0000.00716.63
7.3.280.0100.00716.58
7.3.270.0080.01217.40
7.3.260.0140.00516.67
7.3.250.0130.00716.61
7.3.240.0100.01016.59
7.3.230.0110.00716.55
7.3.210.0210.00316.67
7.3.200.0140.00516.49
7.3.190.0030.01716.78
7.3.180.0100.01316.53
7.3.170.0090.01516.63
7.3.160.0150.00916.79
7.2.330.0060.01316.86
7.2.320.0140.00417.05
7.2.310.0070.01116.95
7.2.300.0050.01416.83
7.2.290.0090.00916.88
7.2.60.0030.01316.72
7.2.00.0030.00919.36
7.1.200.0060.00815.85
7.1.100.0080.00317.88
7.1.70.0080.00016.98
7.1.60.0070.01619.36
7.1.50.0030.02017.23
7.1.00.0070.07722.48
7.0.200.0000.00917.05
7.0.60.0100.06720.03
7.0.50.0030.08718.03
7.0.40.0070.08020.12
7.0.30.0430.07320.30
7.0.20.0200.06020.29
7.0.10.0170.07720.31
7.0.00.0000.04720.27
5.6.280.0000.07721.09
5.6.210.0030.08320.88
5.6.200.0100.04318.25
5.6.190.0000.07320.54
5.6.180.0430.06320.79
5.6.170.0230.05720.62
5.6.160.0230.05020.78
5.6.150.0100.08318.36
5.6.140.0000.04718.38
5.6.130.0170.06018.26
5.6.120.0170.07321.01
5.6.110.0070.05721.02
5.6.100.0130.05321.24
5.6.90.0030.06321.00
5.6.80.0070.03720.63
5.5.350.4130.04320.47
5.5.340.0070.05018.06
5.5.330.0100.08320.64
5.5.320.0030.09020.43
5.5.310.0230.08020.48
5.5.300.0130.05017.99
5.5.290.0070.04018.11
5.5.280.0070.05320.75
5.5.270.0030.05321.02
5.5.260.0170.07020.73
5.5.250.0030.08320.55
5.5.240.0330.05320.21

preferences:
53.26 ms | 401 KiB | 5 Q