3v4l.org

run code in 300+ PHP versions simultaneously
<?php $offsets = [ 1 => [0,2], 2 => [2,5], 3 => [8,9] ]; $html = <<<HTML <div>This is</div> only a test for stackoverflow HTML; $ignoreTag = false; $insertTagStart = false; $char = 0; for ($i = 0; $i < strlen($html); ++$i) { if ($ignoreTag && $html[$i] == '>') { $ignoreTag = false; } elseif ($html[$i] == '<') { if ($insertTagStart !== false) { // insert tag interruption, print closing tag, modify the lookup ++$offsets[$insertTagStart][0]; $html = substr_replace($html, "</span>", $i, 0); $i += 6; // </span> = 7 minus 1 before loop's increment } $ignoreTag = true; } else { foreach ($offsets as $id => $set) { if ($char == $set[0]) { $insertTagStart = $id; $insertTag = "<span class='annotation n-{$id}'>"; $i += strlen($insertTag) - 1; // compensate for inserted substring while traversing html $html = substr_replace($html, $insertTag, $char, 0); } elseif ($insertTagStart == $id && $set[1] == $char) { $html = substr_replace($html, "</span>", $char, 0); $insertTagStart = false; } } ++$char; } echo "{$char},\t" , ($ignoreTag ? 't' : 'f') , ",\t" , ($insertTagStart === false ? 'f' : $insertTagStart) , ",\t" , $html , "\n"; } echo $html;

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.0120.00318.31
8.3.50.0090.00718.30
8.3.40.0160.00618.84
8.3.30.0060.00918.84
8.3.20.0030.00621.83
8.3.10.0000.00821.78
8.3.00.0060.00323.59
8.2.180.0130.00625.92
8.2.170.0090.00622.96
8.2.160.0120.00320.43
8.2.150.0070.00324.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0040.00426.16
8.2.110.0040.00721.04
8.2.100.0090.00318.03
8.2.90.0050.00318.16
8.2.80.0000.00820.36
8.2.70.0000.01017.93
8.2.60.0040.00418.22
8.2.50.0060.00318.10
8.2.40.0000.00819.47
8.2.30.0030.00519.22
8.2.20.0040.00418.20
8.2.10.0150.00318.98
8.2.00.0000.00919.40
8.1.280.0070.01125.92
8.1.270.0060.00322.46
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0070.00422.07
8.1.230.0080.00420.88
8.1.220.0060.00317.78
8.1.210.0000.00818.85
8.1.200.0040.00717.34
8.1.190.0050.00317.23
8.1.180.0090.00018.10
8.1.170.0050.00318.65
8.1.160.0040.00418.98
8.1.150.0000.00818.71
8.1.140.0000.00718.89
8.1.130.0040.00420.18
8.1.120.0060.00317.33
8.1.110.0060.00317.38
8.1.100.0000.00817.43
8.1.90.0040.00417.50
8.1.80.0050.00517.38
8.1.70.0040.00417.50
8.1.60.0030.00517.60
8.1.50.0080.00317.47
8.1.40.0000.00917.56
8.1.30.0030.00517.68
8.1.20.0060.00317.63
8.1.10.0000.00817.67
8.1.00.0060.00317.46
8.0.300.0080.00020.09
8.0.290.0050.00316.75
8.0.280.0000.00818.52
8.0.270.0020.00517.32
8.0.260.0030.00618.48
8.0.250.0030.00517.08
8.0.240.0000.00716.99
8.0.230.0040.00417.00
8.0.220.0040.00417.02
8.0.210.0070.00016.86
8.0.200.0040.00417.06
8.0.190.0050.00316.91
8.0.180.0000.00817.02
8.0.170.0060.00316.91
8.0.160.0040.00416.88
8.0.150.0040.00416.92
8.0.140.0060.00516.88
8.0.130.0040.00413.34
8.0.120.0070.00016.92
8.0.110.0000.00716.95
8.0.100.0030.00516.98
8.0.90.0040.00416.87
8.0.80.0100.00717.04
8.0.70.0000.00717.00
8.0.60.0000.00717.00
8.0.50.0000.00816.88
8.0.30.0100.00917.11
8.0.20.0110.01117.06
8.0.10.0050.00216.99
8.0.00.0120.01016.83
7.4.330.0050.00015.55
7.4.320.0060.00016.52
7.4.300.0070.00016.58
7.4.290.0080.00316.63
7.4.280.0000.00816.54
7.4.270.0040.00416.68
7.4.260.0030.00416.52
7.4.250.0000.00816.61
7.4.240.0040.00316.59
7.4.230.0080.00016.51
7.4.220.0080.00016.56
7.4.210.0090.00816.62
7.4.200.0050.00216.71
7.4.160.0140.00616.69
7.4.130.0160.00316.48
7.4.120.0090.00916.43
7.4.110.0090.00916.63
7.4.100.0160.00316.58
7.4.90.0080.01216.57
7.4.80.0130.00319.39
7.4.70.0140.00516.50
7.4.60.0050.01416.61
7.4.50.0100.00616.39
7.4.40.0190.00016.63
7.4.00.0060.01014.86
7.3.330.0030.00313.14
7.3.320.0000.00613.32
7.3.310.0040.00416.34
7.3.300.0030.00316.41
7.3.290.0000.00716.43
7.3.280.0070.01016.38
7.3.260.0110.00916.51
7.3.230.0150.00616.55
7.3.210.0050.01516.47
7.3.200.0060.01116.40
7.3.190.0100.00916.59
7.3.180.0160.00616.43
7.3.170.0140.00716.39
7.3.160.0060.01316.45
7.3.60.0120.00014.94
7.3.50.0060.01114.85
7.3.40.0090.00314.81
7.3.30.0130.00914.84
7.3.20.0760.00914.72
7.3.10.0150.00014.56
7.3.00.0150.00314.86
7.2.330.0140.00616.63
7.2.320.0160.01016.48
7.2.310.0030.01616.72
7.2.300.0090.00916.65
7.2.290.0100.01416.78
7.2.190.0040.00814.66
7.2.180.0090.01315.02
7.2.170.0120.00015.13
7.2.160.0130.01015.13
7.2.150.0170.00815.12
7.2.140.0100.01015.02
7.2.130.0160.00314.87
7.2.120.0120.00315.17
7.2.110.0070.00714.82
7.2.100.0110.00415.00
7.2.90.0230.00615.02
7.2.80.0090.01615.23
7.2.70.0090.00915.04
7.2.60.0150.00315.03
7.2.50.0220.00914.83
7.2.40.0120.00614.93
7.2.30.0180.00914.91
7.2.20.0150.00014.95
7.2.10.0130.01315.04
7.2.00.0210.00614.94
7.1.300.0220.00313.79
7.1.290.0130.01014.25
7.1.280.0060.00613.66
7.1.270.0060.01813.89
7.1.260.0130.00313.82
7.1.250.0110.00414.12

preferences:
58.28 ms | 401 KiB | 5 Q