3v4l.org

run code in 300+ PHP versions simultaneously
<?php $texts = [ "For example this is the text where I searched the keyword and I need the text around it too.", "keyword at the very start", "Or it can end with keyword", "Nothing to see here officer.", "keyword", ]; $needle = "keyword"; $extra = 10; foreach ($texts as $text) { $new = preg_replace_callback( "/.*?(\S+.{0,$extra})?($needle)(.{0,$extra}\S+)?.*/", function($m) { return sprintf( '%s<b>%s</b>%s', strlen($m[1]) ? "..{$m[1]}" : '', $m[2], strlen($m[3] ?? '') ? "{$m[3]}.." : '' ); }, $text, 1, $count ); echo ($count ? $new : '') . "\n"; }

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.0070.00322.33
8.4.110.0110.00922.50
8.4.100.0110.01018.75
8.4.90.0120.00918.98
8.4.80.0110.01020.38
8.4.70.0110.00918.27
8.4.60.0140.00718.74
8.4.50.0090.00517.96
8.4.40.0060.00317.75
8.4.30.0190.00018.72
8.4.20.0040.00419.77
8.4.10.0090.00023.69
8.3.250.0130.00718.85
8.3.240.0110.00916.52
8.3.230.0100.00916.73
8.3.220.0120.00718.94
8.3.210.0100.00818.55
8.3.200.0070.00316.63
8.3.190.0120.00816.79
8.3.180.0120.00716.89
8.3.170.0100.01018.91
8.3.160.0150.00416.98
8.3.150.0150.00416.92
8.3.140.0030.01618.91
8.3.130.0090.00018.36
8.3.120.0070.00318.74
8.3.110.0140.00620.94
8.3.100.0030.00624.06
8.3.90.0110.00726.77
8.3.80.0070.00317.97
8.3.70.0100.00718.63
8.3.60.0120.00318.43
8.3.50.0060.01216.86
8.3.40.0060.00920.19
8.3.30.0150.00018.92
8.3.20.0070.00024.18
8.3.10.0050.00224.66
8.3.00.0030.00626.16
8.2.290.0030.00620.58
8.2.280.0130.00616.93
8.2.270.0120.00317.14
8.2.260.0140.00418.92
8.2.250.0030.00516.93
8.2.240.0030.00517.18
8.2.230.0100.00022.58
8.2.220.0070.00337.54
8.2.210.0000.00826.77
8.2.200.0000.01016.63
8.2.190.0070.01116.86
8.2.180.0060.00916.86
8.2.170.0170.00319.21
8.2.160.0070.00722.96
8.2.150.0060.00325.66
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00417.88
8.2.110.0070.00321.16
8.2.100.0060.00617.97
8.2.90.0080.00018.09
8.2.80.0060.00319.15
8.2.70.0060.00317.75
8.2.60.0050.00317.75
8.2.50.0160.00319.14
8.2.40.0090.00619.14
8.2.30.0120.00519.14
8.2.20.0120.00619.14
8.2.10.0130.00519.14
8.2.00.0170.00219.14
8.1.330.0170.00722.11
8.1.320.0080.01116.33
8.1.310.0130.00616.63
8.1.300.0080.01120.16
8.1.290.0060.00318.88
8.1.280.0100.00625.92
8.1.270.0040.00424.66
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0070.00323.84
8.1.230.0030.00620.90
8.1.220.0040.00417.74
8.1.210.0070.00318.89
8.1.200.0060.00317.63
8.1.190.0040.00417.48
8.1.180.0120.00619.14
8.1.170.0090.00819.14
8.1.160.0130.00419.14
8.1.150.0110.00619.14
8.1.140.0120.00419.14
8.1.130.0130.00419.14
8.1.120.0120.00519.37
8.1.110.0140.00419.14
8.1.100.0080.00819.14
8.1.90.0120.00519.14
8.1.80.0100.00719.14
8.1.70.0110.00619.14
8.1.60.0120.00719.14
8.1.50.0140.00419.14
8.1.40.0120.00619.14
8.1.30.0160.00319.14
8.1.20.0130.00519.14
8.1.10.0130.00519.14
8.1.00.0120.00619.14
8.0.300.0040.00420.09
8.0.290.0040.00416.88
8.0.280.0090.00619.14
8.0.270.0150.00219.14
8.0.260.0130.00519.14
8.0.250.0110.00519.14
8.0.240.0130.00519.14
8.0.230.0090.00819.14
8.0.220.0140.00419.14
8.0.210.0120.00519.14
8.0.200.0090.00819.14
8.0.190.0100.00619.14
8.0.180.0120.00719.14
8.0.170.0100.00619.14
8.0.160.0110.00519.14
8.0.150.0110.00619.14
8.0.140.0130.00419.14
8.0.130.0140.00419.14
8.0.120.0140.00319.14
8.0.110.0130.00319.14
8.0.100.0110.00619.14
8.0.90.0140.00319.14
8.0.80.0140.00319.14
8.0.70.0110.00619.14
8.0.60.0130.00319.14
8.0.50.0120.00419.14
8.0.30.0150.00319.14
8.0.20.0120.00519.14
8.0.10.0090.00819.14

preferences:
29.4 ms | 403 KiB | 5 Q