3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = 'abdabc'; $needle = 'c'; $replace = 'z'; $limit = 2; function str_replace_limit($haystack, $needle, $replace, $limit, $start_pos = 0) { if ($limit < 1 || ($pos = strpos($haystack,$needle,$start_pos)) === false) { return $haystack; } else { return str_replace_limit( substr_replace($haystack, $replace, $pos, strlen($needle)), $needle, $replace, $limit - 1, $pos + strlen($replace) ); } } echo str_replace_limit($haystack, $needle, $replace, $limit);

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.0070.00718.34
8.3.40.0170.00418.64
8.3.30.0120.00318.54
8.3.20.0000.00821.74
8.3.10.0080.00020.44
8.3.00.0080.00019.25
8.2.180.0110.00418.16
8.2.170.0070.01422.96
8.2.160.0030.01019.29
8.2.150.0070.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00821.00
8.2.110.0070.00321.11
8.2.100.0070.00417.78
8.2.90.0080.00018.07
8.2.80.0050.00317.97
8.2.70.0030.00617.80
8.2.60.0080.00018.22
8.2.50.0000.00918.10
8.2.40.0080.00021.09
8.2.30.0040.00419.35
8.2.20.0000.00818.14
8.2.10.0000.00819.50
8.2.00.0040.00418.07
8.1.280.0110.00325.92
8.1.270.0040.00420.24
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0090.00020.77
8.1.230.0040.00820.65
8.1.220.0050.00317.74
8.1.210.0000.00918.84
8.1.200.0030.00717.23
8.1.190.0030.00617.22
8.1.180.0030.00518.10
8.1.170.0000.00818.58
8.1.160.0040.00418.85
8.1.150.0030.00618.81
8.1.140.0000.00720.27
8.1.130.0000.00717.42
8.1.120.0080.00417.46
8.1.110.0000.00717.38
8.1.100.0040.00417.50
8.1.90.0040.00417.48
8.1.80.0040.00417.43
8.1.70.0000.00917.36
8.1.60.0040.00417.64
8.1.50.0050.00317.52
8.1.40.0070.00017.53
8.1.30.0040.00417.68
8.1.20.0060.00317.68
8.1.10.0040.00417.53
8.1.00.0080.00017.44
8.0.300.0000.00719.93
8.0.290.0040.00416.63
8.0.280.0070.00018.44
8.0.270.0000.00717.22
8.0.260.0030.00316.79
8.0.250.0040.00416.94
8.0.240.0000.00816.99
8.0.230.0040.00316.89
8.0.220.0030.00316.91
8.0.210.0080.00016.76
8.0.200.0030.00316.95
8.0.190.0000.00716.96
8.0.180.0030.00516.92
8.0.170.0060.00316.95
8.0.160.0040.00416.97
8.0.150.0000.00716.83
8.0.140.0040.00416.91
8.0.130.0060.00013.38
8.0.120.0040.00416.79
8.0.110.0000.00816.82
8.0.100.0000.00716.83
8.0.90.0040.00416.94
8.0.80.0150.00016.88
8.0.70.0040.00416.96
8.0.60.0000.00716.96
8.0.50.0040.00416.78
8.0.30.0080.00916.96
8.0.20.0140.00617.05
8.0.10.0060.00817.06
8.0.00.0090.00916.87
7.4.330.0050.00015.55
7.4.320.0030.00316.55
7.4.300.0030.00316.58
7.4.290.0000.00716.60
7.4.280.0040.00416.57
7.4.270.0000.00616.61
7.4.260.0000.00816.51
7.4.250.0030.00316.57
7.4.240.0070.00016.67
7.4.230.0000.00716.50
7.4.220.0040.00416.56
7.4.210.0060.00916.56
7.4.200.0070.00016.61
7.4.160.0090.00816.54
7.4.150.0080.00616.52
7.4.140.0080.00817.13
7.4.130.0100.00716.54
7.4.120.0070.00916.54
7.4.110.0070.00916.56
7.4.100.0040.01316.59
7.4.90.0070.01016.46
7.4.80.0050.01117.46
7.4.70.0040.01516.46
7.4.60.0040.01216.47
7.4.50.0040.01416.42
7.4.40.0120.00416.36
7.4.30.0070.00916.46
7.4.20.0030.01116.39
7.4.10.0060.00816.48
7.4.00.0090.00615.72
7.3.330.0000.00613.37
7.3.320.0000.00613.40
7.3.310.0000.00716.40
7.3.300.0030.00316.25
7.3.290.0150.00616.29
7.3.280.0070.00816.37
7.3.270.0070.01016.37
7.3.260.0070.01216.44
7.3.250.0050.00916.34
7.3.240.0070.00916.49
7.3.230.0080.01016.37
7.3.220.0120.00416.29
7.3.210.0080.00816.34
7.3.200.0060.01016.36
7.3.190.0110.00716.40
7.3.180.0070.01016.32
7.3.170.0060.01016.35
7.3.160.0100.00816.37
7.3.150.0070.00716.35
7.3.140.0060.00816.34
7.3.130.0020.01216.27
7.3.120.0110.00515.87
7.3.110.0060.00815.76
7.3.100.0060.00915.72
7.3.90.0090.00515.99
7.3.80.0060.00815.81
7.3.70.0060.01015.94
7.3.60.0080.00815.85
7.3.50.0130.00315.85
7.3.40.0100.00615.97
7.3.30.0080.00515.86
7.3.20.0210.00816.13
7.3.10.0200.00716.02
7.3.00.0190.00616.09
7.2.340.0130.01216.39
7.2.330.0130.00616.50
7.2.320.0160.00616.47
7.2.310.0130.00716.41
7.2.300.0130.00816.45
7.2.290.0110.00916.45
7.2.280.0170.00616.38
7.2.270.0120.00816.39
7.2.260.0060.00916.39
7.2.250.0090.00915.98
7.2.240.0110.00915.98
7.2.230.0090.00815.88
7.2.220.0110.00815.92
7.2.210.0140.00615.82
7.2.200.0090.00615.95
7.2.190.0070.01016.04
7.2.180.0090.00915.97
7.2.170.0070.01015.99
7.2.160.0170.00516.54
7.2.150.0250.01016.12
7.2.140.0220.00916.12
7.2.130.0230.00816.21
7.2.120.0230.00816.18
7.2.110.0250.00916.15
7.2.100.0260.00416.12
7.2.90.0260.00816.06
7.2.80.0330.00915.99
7.2.70.0250.01316.02
7.2.60.0270.01216.15
7.2.50.0290.00815.95
7.2.40.0280.00916.15
7.2.30.0320.01116.14
7.2.20.0260.01116.12
7.2.10.0290.00916.06
7.2.00.0250.00916.16
7.1.330.0120.00615.64
7.1.320.0080.00815.65
7.1.310.0090.00615.73
7.1.300.0090.00515.72
7.1.290.0110.00715.70
7.1.280.0090.01215.55
7.1.270.0110.00615.65
7.1.260.0080.00915.56
7.1.250.0230.00814.96
7.1.240.0180.00715.51
7.1.230.0090.00915.60
7.1.220.0090.01015.52
7.1.210.0160.00615.61
7.1.200.0200.00615.59
7.1.190.0140.00715.55
7.1.180.0120.00915.46
7.1.170.0150.01015.46
7.1.160.0220.00815.54
7.1.150.0140.00715.48
7.1.140.0140.00815.51
7.1.130.0110.00815.53
7.1.120.0090.01015.50
7.1.110.0150.00415.50
7.1.100.0090.01015.46
7.1.90.0180.00815.54
7.1.80.0140.00615.57
7.1.70.0140.00515.35
7.1.60.0140.00715.61
7.1.50.0180.00115.65
7.1.40.0080.01315.62
7.1.30.0150.00715.54
7.1.20.0110.00615.50
7.1.10.0090.00515.42
7.1.00.0080.00715.48

preferences:
57.41 ms | 401 KiB | 5 Q