3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = 'Here are @user:123 and @user:456 mentions'; $contextSize = 5; $pattern = '~ @user:[0-9]+ \s* (*:mention) | \S+ \s* ~x'; $results = []; if (preg_match_all($pattern, $text, $matches)) { foreach ($matches['MARK'] as $k => $v) { $beforeIndex = max(0, $k - $contextSize); $beforeSize = $k - $beforeIndex; $afterIndex = $k + 1; $results[] = [ 'before' => join(array_slice($matches[0], $beforeIndex, $beforeSize)), 'mention' => $matches[0][$k], 'after' => join(array_slice($matches[0], $afterIndex, $contextSize)) ]; } } print_r($results);

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.5.00.0100.01120.14
8.4.150.0020.00014.05
8.4.140.0170.00517.55
8.4.130.0040.00517.91
8.4.120.0120.00824.09
8.4.110.0050.00424.33
8.4.100.0100.01018.15
8.4.90.0120.00917.79
8.4.80.0160.00417.90
8.4.70.0050.00418.07
8.4.60.0100.01119.06
8.4.50.0130.00718.03
8.4.40.0100.01017.79
8.4.30.0100.01018.67
8.4.20.0080.01219.66
8.4.10.0060.00319.42
8.3.280.0130.00818.60
8.3.270.0120.01016.90
8.3.260.0100.00917.19
8.3.250.0040.00318.97
8.3.240.0090.00719.14
8.3.230.0100.01016.52
8.3.220.0100.00817.40
8.3.210.0140.00516.86
8.3.200.0040.00616.78
8.3.190.0090.00718.51
8.3.180.0120.00816.74
8.3.170.0190.00018.93
8.3.160.0090.00917.08
8.3.150.0150.00317.40
8.3.140.0080.00817.29
8.3.130.0090.00918.47
8.3.120.0040.01220.67
8.3.110.0100.01020.94
8.3.100.0040.00724.06
8.3.90.0120.00826.77
8.3.80.0060.00318.81
8.3.70.0070.01416.75
8.3.60.0090.00916.99
8.3.50.0070.01116.64
8.3.40.0040.01121.88
8.3.30.0090.00620.28
8.3.20.0120.00923.48
8.3.10.0120.00923.60
8.3.00.0170.00320.97
8.2.290.0070.00122.22
8.2.280.0090.00418.52
8.2.270.0110.00717.13
8.2.260.0040.01116.75
8.2.250.0150.00016.57
8.2.240.0090.00017.23
8.2.230.0030.01222.58
8.2.220.0080.00037.54
8.2.210.0060.01226.77
8.2.200.0040.00418.79
8.2.190.0160.00616.88
8.2.180.0150.00316.75
8.2.170.0100.00722.96
8.2.160.0070.01022.27
8.2.150.0180.00421.00
8.2.140.0030.01722.38
8.2.130.0030.01322.38
8.2.120.0110.01121.08
8.2.110.0140.00721.13
8.2.100.0040.01121.00
8.2.90.0140.00720.85
8.2.80.0120.00321.43
8.2.70.0140.00720.73
8.2.60.0130.01020.75
8.2.50.0140.00721.13
8.2.40.0080.01120.73
8.2.30.0120.00620.72
8.2.20.0150.00420.50
8.2.10.0070.01120.73
8.2.00.0110.00720.50
8.1.330.0110.00816.82
8.1.320.0110.00818.26
8.1.310.0050.00318.68
8.1.300.0150.00418.36
8.1.290.0000.01130.84
8.1.280.0120.00325.92
8.1.270.0120.00623.91
8.1.260.0100.00723.73
8.1.250.0140.00723.91
8.1.240.0110.01120.39
8.1.230.0120.00818.69
8.1.220.0100.01020.78
8.1.210.0130.00720.33
8.1.200.0110.00920.64
8.1.190.0120.00620.37
8.1.180.0100.00620.16
8.1.170.0110.00320.47
8.1.160.0040.01220.47
8.1.150.0110.00420.51
8.1.140.0120.00320.43
8.1.130.0110.00320.64
8.1.120.0040.01120.44
8.1.110.0070.00720.58
8.1.100.0090.00621.63
8.1.90.0070.00720.53
8.1.80.0040.01121.72
8.1.70.0040.01120.50
8.1.60.0140.00020.53
8.1.50.0120.00320.58
8.1.40.0000.01520.55
8.1.30.0150.00020.63
8.1.20.0060.00921.88
8.1.10.0070.00720.52
8.1.00.0040.01120.47

preferences:
29.38 ms | 403 KiB | 5 Q