3v4l.org

run code in 300+ PHP versions simultaneously
<?php $originalString = "Hello world, what do you think of today's weather"; $findString = ' '; $nthOccurrence = 8; $newWord = ' beautiful '; function replaceNth(string $input, string $find, string $replacement, int $nth = 1): string { $pattern = '/(?:.*?\K' . preg_quote($find, '/') . '){' . $nth . '}/'; return preg_replace($pattern, $replacement, $input, 1); } echo replaceNth($originalString, $findString, $newWord, $nthOccurrence);

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.140.0140.00918.07
8.4.130.0130.00718.88
8.4.120.0140.00624.14
8.4.110.0140.00818.90
8.4.100.0140.00618.89
8.4.90.0130.00820.71
8.4.80.0120.00919.84
8.4.70.0050.00418.24
8.4.60.0130.00720.56
8.4.50.0120.00919.66
8.4.40.0160.01019.47
8.4.30.0130.01020.41
8.4.20.0030.01618.81
8.4.10.0060.00317.91
8.3.270.0120.00816.85
8.3.260.0060.00316.70
8.3.250.0140.00318.98
8.3.240.0070.01217.09
8.3.230.0110.00816.51
8.3.220.0030.00518.98
8.3.210.0080.01016.68
8.3.200.0060.00216.90
8.3.190.0110.00618.96
8.3.180.0100.00516.93
8.3.170.0150.00318.98
8.3.160.0120.00616.69
8.3.150.0140.00420.78
8.3.140.0060.00318.63
8.3.130.0030.00618.56
8.3.120.0080.00020.59
8.3.110.0040.00720.94
8.3.100.0060.01116.91
8.3.90.0050.00326.77
8.3.80.0060.00316.63
8.3.70.0070.01418.43
8.3.60.0090.00918.48
8.3.50.0170.00316.49
8.3.40.0070.00719.09
8.3.30.0110.00418.84
8.3.20.0000.00724.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.290.0110.00820.20
8.2.280.0050.00418.47
8.2.270.0120.00319.21
8.2.260.0070.00718.57
8.2.250.0060.01316.84
8.2.240.0040.00417.41
8.2.230.0000.01022.58
8.2.220.0060.00324.06
8.2.210.0040.00426.77
8.2.200.0030.00616.75
8.2.190.0150.00017.00
8.2.180.0080.00825.92
8.2.170.0110.00422.96
8.2.160.0030.01022.96
8.2.150.0080.00025.66
8.2.140.0100.00024.66
8.2.130.0030.00626.16
8.2.120.0080.00019.96
8.2.110.0060.00320.19
8.2.100.0070.00417.84
8.2.90.0000.00817.88
8.2.80.0050.00319.03
8.2.70.0030.00618.04
8.2.60.0040.00418.22
8.2.50.0030.00518.10
8.2.40.0050.00321.28
8.2.30.0050.00219.16
8.2.20.0000.00818.09
8.2.10.0050.00219.34
8.2.00.0050.00319.28
8.1.330.0110.00922.27
8.1.320.0140.00616.39
8.1.310.0000.00816.52
8.1.300.0030.00618.10
8.1.290.0060.00330.84
8.1.280.0070.00725.92
8.1.270.0070.00023.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0130.01019.14
8.1.230.0080.00417.83
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0000.01017.36
8.1.190.0050.00317.35
8.1.180.0060.00318.10
8.1.170.0030.00718.78
8.1.160.0040.00418.96
8.1.150.0000.00718.80
8.1.140.0000.00718.93
8.1.130.0070.00020.18
8.1.120.0000.00717.66
8.1.110.0040.00417.61
8.1.100.0040.00417.64
8.1.90.0080.00017.65
8.1.80.0040.00417.63
8.1.70.0050.00317.52
8.1.60.0040.00417.78
8.1.50.0040.00417.67
8.1.40.0000.00817.71
8.1.30.0030.00517.77
8.1.20.0060.00317.79
8.1.10.0040.00417.73
8.1.00.0030.00517.58
8.0.300.0080.00018.94
8.0.290.0040.00416.75
8.0.280.0000.00718.40
8.0.270.0040.00416.89
8.0.260.0060.00018.47
8.0.250.0040.00417.05
8.0.240.0000.00717.12
8.0.230.0030.00316.98
8.0.220.0040.00416.97
8.0.210.0000.00717.06
8.0.200.0000.00717.05
8.0.190.0030.00517.13
8.0.180.0040.00417.11
8.0.170.0060.00317.05
8.0.160.0040.00417.04
8.0.150.0070.00316.93
8.0.140.0070.00016.93
8.0.130.0030.00313.43
8.0.120.0040.00416.99
8.0.110.0050.00217.00
8.0.100.0030.00516.99
8.0.90.0000.00817.09
8.0.80.0060.00917.03
8.0.70.0000.00816.86
8.0.60.0000.00716.95
8.0.50.0030.00616.82
8.0.30.0120.00917.08
8.0.20.0060.01516.98
8.0.10.0110.01117.07
8.0.00.0090.00917.11
7.4.330.0050.00015.55
7.4.320.0070.00016.70
7.4.300.0000.00616.73
7.4.290.0030.00316.67
7.4.280.0080.00016.73
7.4.270.0000.00716.89
7.4.260.0050.00013.61
7.4.250.0000.00716.78
7.4.240.0070.00016.83
7.4.230.0040.00416.92
7.4.220.0020.00516.82
7.4.210.0080.00816.74
7.4.200.0000.00716.85
7.4.160.0070.01416.84
7.4.150.0030.01516.65
7.4.140.0100.00416.68
7.4.130.0030.01716.80
7.4.120.0100.01316.68
7.4.110.0130.00316.74
7.4.100.0100.01016.80
7.4.90.0140.00616.77
7.4.80.0100.01016.68
7.4.70.0180.00416.68
7.4.60.0070.01516.77
7.4.50.0000.01716.68
7.4.40.0090.01516.78
7.4.30.0030.01916.64
7.4.20.0130.01316.53
7.4.10.0040.01516.67
7.4.00.0060.01516.77
7.3.330.0000.00716.56
7.3.320.0030.00313.29
7.3.310.0020.00516.49
7.3.300.0030.00316.33
7.3.290.0070.01116.46
7.3.270.0170.00316.45
7.3.260.0030.01616.44
7.3.250.0120.00616.48
7.3.240.0120.01016.36
7.3.230.0090.00916.40
7.3.220.0160.00316.46
7.3.210.0100.00916.46
7.3.200.0060.01316.52
7.3.190.0090.01216.41
7.3.180.0110.00716.48
7.3.170.0090.00916.43
7.3.160.0040.01416.47
7.3.150.0030.01516.44
7.3.140.0040.01816.45
7.3.130.0070.01316.42
7.3.120.0060.01616.38
7.3.110.0060.01316.34
7.3.100.0060.02116.28
7.3.90.0090.01716.76
7.3.80.0100.01016.37
7.3.70.0150.00716.47
7.3.60.0170.00416.69
7.3.50.0100.01016.67
7.3.40.0090.00916.54
7.3.30.0070.01016.59
7.3.20.0090.01216.65
7.3.10.0060.01216.56
7.3.00.0080.00816.53

preferences:
131.63 ms | 403 KiB | 5 Q