3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'III.OOO.OOO.OOO.S'; $search = 'XXX'; $replace = 'B'; //replace ONLY FIRST occurance of "OOO" with "B" echo substr_replace($string,$replace,0,strlen($search)); //$string => B.OOO.OOO.S echo "\n---\n"; //replace ONLY LAST occurance of "OOOO" with "B" echo substr_replace($string,$replace,strrpos($string,$search),strlen($search)); //$string => OOO.OOO.B.S echo "\n---\n"; //replace ONLY LAST occurance of "OOOO" with "B" echo strrev(implode(strrev($replace),explode(strrev($search),strrev($string),2))); //$string => OOO.OOO.B.S

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.40.0070.01118.67
8.3.30.0140.00018.50
8.3.20.0040.00421.73
8.3.10.0060.00320.34
8.3.00.0030.00519.25
8.2.170.0040.01119.01
8.2.160.0150.00419.27
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0080.00017.97
8.2.120.0040.00426.35
8.2.110.0070.00320.90
8.2.100.0110.00017.91
8.2.90.0090.00017.91
8.2.80.0000.00817.97
8.2.70.0060.00618.04
8.2.60.0000.00817.91
8.2.50.0000.00818.10
8.2.40.0040.00421.18
8.2.30.0000.00719.21
8.2.20.0030.00518.03
8.2.10.0070.00019.37
8.2.00.0040.00417.97
8.1.270.0060.00320.32
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.97
8.1.230.0080.00421.03
8.1.220.0000.00717.79
8.1.210.0050.00318.77
8.1.200.0000.00817.23
8.1.190.0050.00317.23
8.1.180.0060.00318.10
8.1.170.0070.00318.57
8.1.160.0040.00418.80
8.1.150.0000.00718.81
8.1.140.0030.00320.25
8.1.130.0080.00020.20
8.1.120.0080.00017.42
8.1.110.0040.00417.38
8.1.100.0000.00717.40
8.1.90.0000.00817.26
8.1.80.0000.00817.31
8.1.70.0040.00417.40
8.1.60.0000.00717.54
8.1.50.0040.00417.45
8.1.40.0000.00817.41
8.1.30.0030.00517.54
8.1.20.0030.00517.49
8.1.10.0040.00417.39
8.1.00.0080.00017.32
8.0.300.0030.00619.55
8.0.290.0050.00316.75
8.0.280.0070.00018.37
8.0.270.0070.00016.79
8.0.260.0000.00618.34
8.0.250.0070.00016.88
8.0.240.0000.00816.83
8.0.230.0000.00816.74
8.0.220.0030.00316.71
8.0.210.0000.00716.68
8.0.200.0000.00616.90
8.0.190.0030.00516.76
8.0.180.0050.00316.75
8.0.170.0040.00416.82
8.0.160.0000.00716.68
8.0.150.0030.00316.79
8.0.140.0030.00316.80
8.0.130.0000.00513.24
8.0.120.0000.00716.68
8.0.110.0000.00716.74
8.0.100.0000.00716.91
8.0.90.0040.00416.73
8.0.80.0040.01116.76
8.0.70.0000.00716.76
8.0.60.0000.00716.70
8.0.50.0000.00716.77
8.0.30.0100.01016.90
8.0.20.0180.00916.96
8.0.10.0000.00716.92
8.0.00.0070.01416.79
7.4.330.0000.00515.55
7.4.320.0030.00616.42
7.4.300.0030.00316.47
7.4.290.0030.00316.46
7.4.280.0080.00016.52
7.4.270.0000.00716.44
7.4.260.0030.00316.48
7.4.250.0070.00016.54
7.4.240.0000.00816.36
7.4.230.0030.00316.31
7.4.220.0030.00516.43
7.4.210.0110.00516.47
7.4.200.0000.00816.36
7.4.160.0090.00716.44
7.4.140.0110.00817.86
7.4.130.0100.00716.30
7.4.120.0070.01116.64
7.4.110.0110.00716.32
7.4.100.0090.01316.48
7.4.90.0170.00316.50
7.4.80.0070.01119.39
7.4.70.0110.00616.46
7.4.60.0070.01016.27
7.4.50.0060.00916.29
7.4.40.0130.00316.51
7.4.10.0110.00714.88
7.4.00.0050.01214.80
7.3.330.0050.00013.07
7.3.320.0000.00513.03
7.3.310.0070.00016.13
7.3.300.0050.00216.08
7.3.290.0000.00716.23
7.3.280.0080.01016.18
7.3.260.0110.00916.25
7.3.240.0110.00616.31
7.3.230.0070.01016.31
7.3.210.0110.00516.60
7.3.200.0060.00916.57
7.3.190.0030.01916.44
7.3.180.0070.01016.29
7.3.170.0110.00616.54
7.3.160.0030.01316.08
7.3.130.0030.00714.81
7.3.120.0100.00714.85
7.3.110.0070.00814.62
7.3.100.0100.00614.61
7.3.90.0030.01214.74
7.3.80.0090.00214.76
7.3.70.0020.01114.61
7.3.60.0020.01114.84
7.3.50.0050.00714.80
7.3.40.0050.00714.67
7.3.30.0010.00914.69
7.3.20.0420.00715.81
7.3.10.0530.00515.91
7.3.00.0390.01115.91
7.2.330.0090.01016.14
7.2.320.0160.00616.31
7.2.310.0060.01016.58
7.2.300.0060.01216.67
7.2.290.0080.00816.34
7.2.260.0120.00814.96
7.2.250.0070.01014.78
7.2.240.0080.00614.84
7.2.230.0090.00814.73
7.2.220.0070.01014.75
7.2.210.0050.00814.89
7.2.200.0020.01414.92
7.2.190.0050.01014.91
7.2.180.0060.00714.63
7.2.170.0030.01114.81
7.2.160.0070.00814.74
7.2.150.0470.01416.01
7.2.140.0310.00815.96
7.2.130.0380.00616.21
7.2.120.0390.00915.97
7.2.110.0280.00916.22
7.2.100.0300.00916.07
7.2.90.0390.01016.20
7.2.80.0270.01316.17
7.2.70.0380.01016.14
7.2.60.0260.00616.11
7.2.50.0300.00816.20
7.2.40.0310.00916.17
7.2.30.0360.01016.23
7.2.20.0390.00716.15
7.2.10.0420.01215.92
7.2.00.0450.00516.15
7.1.330.0050.00715.73
7.1.320.0070.00715.77
7.1.310.0080.00815.87
7.1.300.0050.00715.76
7.1.290.0080.00715.77
7.1.280.0080.00415.70
7.1.270.0060.00815.51
7.1.260.0050.00715.74
7.1.250.0380.00815.09
7.1.240.0030.00615.32
7.1.230.0040.01215.86
7.1.220.0100.00315.95
7.1.210.0000.00815.82
7.1.200.0060.00315.90
7.1.190.0100.00715.80
7.1.180.0070.00715.79
7.1.170.0030.01015.74
7.1.160.0000.01015.75
7.1.150.0060.00615.66
7.1.140.0030.01215.82
7.1.130.0000.01115.82
7.1.120.0000.01415.95
7.1.110.0000.01515.69
7.1.100.0060.00615.83
7.1.90.0000.01415.78
7.1.80.0030.01015.75
7.1.70.0030.01215.79
7.1.60.0040.00815.75
7.1.50.0080.00415.84
7.1.40.0060.00615.72
7.1.30.0040.00415.77
7.1.20.0030.00915.61
7.1.10.0070.00715.81
7.1.00.0030.01215.95

preferences:
55.18 ms | 400 KiB | 5 Q