3v4l.org

run code in 300+ PHP versions simultaneously
<?php $search = 'The'; $replace = 'A'; $subject = "The Quick Brown Fox Jumps Over The Lazy Dog's Thermos!"; function str_rreplace($search, $replace, $subject) { return (false !== $pos = strrpos($subject, $search)) ? substr_replace($subject, $replace, $pos, strlen($search)) : $subject; } function preg_rreplace($search, $replace, $subject) { preg_match_all($search, $subject, $matches, PREG_SET_ORDER); return ($lastMatch = end($matches)) ? str_rreplace($lastMatch[0], $replace, $subject) : $subject; } echo str_rreplace($search, $replace, $subject) . "\n---\n" . preg_rreplace($search, $replace, $subject);

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.0150.00618.43
8.3.50.0040.01116.71
8.3.40.0070.01322.08
8.3.30.0120.00318.75
8.3.20.0070.00024.18
8.3.10.0000.00824.66
8.3.00.0000.00826.16
8.2.180.0110.01125.92
8.2.170.0120.00319.00
8.2.160.0080.00622.96
8.2.150.0040.00425.66
8.2.140.0000.00724.66
8.2.130.0000.00726.16
8.2.120.0040.00421.06
8.2.110.0050.00520.49
8.2.100.0030.00917.88
8.2.90.0040.00417.78
8.2.80.0000.00917.97
8.2.70.0040.00417.93
8.2.60.0050.00318.09
8.2.50.0060.00318.10
8.2.40.0050.00319.22
8.2.30.0040.00419.09
8.2.20.0000.00818.08
8.2.10.0040.00419.26
8.2.00.0060.00319.27
8.1.280.0140.00425.92
8.1.270.0040.00423.99
8.1.260.0150.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.05
8.1.230.0110.00022.63
8.1.220.0000.00817.76
8.1.210.0000.00818.78
8.1.200.0030.00617.22
8.1.190.0030.00517.36
8.1.180.0080.00018.10
8.1.170.0050.00318.64
8.1.160.0000.00718.95
8.1.150.0070.00018.91
8.1.140.0020.00520.61
8.1.130.0000.00720.09
8.1.120.0060.00317.48
8.1.110.0050.00317.44
8.1.100.0040.00417.45
8.1.90.0070.00017.40
8.1.80.0000.00917.38
8.1.70.0080.00017.52
8.1.60.0090.00017.49
8.1.50.0000.00717.50
8.1.40.0030.00517.54
8.1.30.0040.00417.67
8.1.20.0040.00417.72
8.1.10.0070.00017.59
8.1.00.0070.00017.46
8.0.300.0040.00421.57
8.0.290.0000.00816.63
8.0.280.0040.00418.45
8.0.270.0030.00316.81
8.0.260.0030.00318.49
8.0.250.0000.00817.06
8.0.240.0030.00517.11
8.0.230.0070.00016.91
8.0.220.0000.00716.95
8.0.210.0040.00416.89
8.0.200.0030.00316.92
8.0.190.0050.00317.00
8.0.180.0040.00416.95
8.0.170.0040.00416.98
8.0.160.0000.00717.00
8.0.150.0030.00316.86
8.0.140.0070.00016.95
8.0.130.0060.00013.41
8.0.120.0070.00016.95
8.0.110.0000.00817.03
8.0.100.0020.00517.09
8.0.90.0070.00016.99
8.0.80.0040.01416.97
8.0.70.0050.00317.04
8.0.60.0000.00716.90
8.0.50.0040.00416.72
8.0.30.0100.00716.96
8.0.20.0120.00817.22
8.0.10.0040.00417.09
8.0.00.0110.00816.77
7.4.330.0050.00015.55
7.4.320.0000.00616.55
7.4.300.0000.00616.52
7.4.290.0040.00416.62
7.4.280.0040.00416.51
7.4.270.0000.00816.64
7.4.260.0000.00613.41
7.4.250.0000.00716.58
7.4.240.0000.00816.53
7.4.230.0050.00316.59
7.4.220.0030.00316.70
7.4.210.0080.00916.59
7.4.200.0070.00016.40
7.4.130.0060.01516.61
7.4.120.0180.00016.54
7.4.110.0120.00816.65
7.4.100.0100.01416.70
7.4.90.0100.00716.34
7.4.80.0100.00616.32
7.4.70.0070.01016.75
7.4.60.0120.00616.47
7.4.50.0090.00816.59
7.4.40.0090.00916.61
7.4.30.0130.00616.66
7.4.20.0070.01116.49
7.4.10.0080.00816.43
7.4.00.0100.00716.48
7.3.330.0030.00616.42
7.3.320.0050.00013.27
7.3.310.0080.00016.40
7.3.300.0030.00316.38
7.3.290.0050.01216.40
7.3.260.0090.01516.28
7.3.240.0120.00616.20
7.3.230.0110.00816.43
7.3.220.0110.00616.52
7.3.210.0030.01516.42
7.3.200.0110.00616.43
7.3.190.0140.00316.38
7.3.180.0070.01016.16
7.3.170.0030.01416.30
7.3.160.0070.01016.48
7.3.150.0110.00716.16
7.3.140.0040.01216.48
7.3.130.0070.01116.55
7.3.120.0100.00616.41
7.3.110.0170.00016.33
7.3.100.0120.00616.57
7.3.90.0120.00616.50
7.3.80.0120.01216.53
7.3.70.0000.01816.41
7.3.60.0130.01016.34
7.3.50.0190.00416.40
7.3.40.0090.00916.11
7.3.30.0070.01116.47
7.3.20.0100.00616.40
7.3.10.0080.00816.51
7.3.00.0130.00316.34
7.2.340.0100.01016.70
7.2.330.0090.00616.71
7.2.320.0080.01116.25
7.2.310.0140.00316.67
7.2.300.0090.00916.63
7.2.290.0100.00716.63
7.2.280.0070.01016.42
7.2.270.0060.01216.54
7.2.260.0120.00616.72
7.2.250.0100.00716.57
7.2.240.0150.00616.53
7.2.230.0070.01116.45
7.2.220.0120.00616.38
7.2.210.0070.01716.48
7.2.200.0090.00916.52
7.2.190.0070.01016.57
7.2.180.0100.01316.59
7.2.170.0070.01116.63
7.2.160.0080.00816.70
7.2.150.0040.01516.68
7.2.140.0060.01216.66
7.2.130.0100.00716.52
7.2.120.0230.01016.57
7.2.110.0090.01616.63
7.2.100.0160.00916.60
7.2.90.0060.01216.64
7.2.80.0160.00616.70
7.2.70.0140.00516.73
7.2.60.0120.00616.64
7.2.50.0100.01016.52
7.2.40.0070.01016.63
7.2.30.0070.01016.68
7.2.20.0090.00916.48
7.2.10.0120.00616.55
7.2.00.0120.00616.47

preferences:
57.41 ms | 400 KiB | 5 Q