3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'III.OOO.OOO.S'; $search = 'OOO'; $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.1.60.0030.00617.48
8.1.50.0050.00317.48
8.1.40.0040.00417.40
8.1.30.0000.00717.53
8.1.20.0030.00617.58
8.1.10.0000.00717.40
8.1.00.0000.00817.45
8.0.190.0080.00016.84
8.0.180.0000.00816.83
8.0.170.0100.00016.77
8.0.160.0000.00816.82
8.0.150.0040.00316.82
8.0.140.0000.00716.79
8.0.130.0060.00013.23
8.0.120.0020.00516.69
8.0.110.0040.00416.72
8.0.100.0000.00716.64
8.0.90.0050.00316.68
8.0.80.0030.01216.77
8.0.70.0030.00516.94
8.0.60.0040.00416.80
8.0.50.0040.00416.75
8.0.30.0080.00817.22
8.0.20.0060.01417.19
8.0.10.0000.00716.78
8.0.00.0100.00916.79
7.4.290.0000.00616.52
7.4.280.0000.00716.52
7.4.270.0040.00416.38
7.4.260.0030.00316.43
7.4.250.0000.00716.53
7.4.240.0070.00016.53
7.4.230.0070.00016.40
7.4.220.0070.00016.23
7.4.210.0040.01016.48
7.4.200.0030.00316.55
7.4.160.0070.00916.39
7.4.140.0140.00417.86
7.4.130.0130.00616.46
7.4.120.0030.01416.46
7.4.110.0170.00716.58
7.4.100.0140.00916.46
7.4.90.0140.00316.32
7.4.80.0090.00919.39
7.4.70.0040.01416.55
7.4.60.0060.01216.37
7.4.50.0040.00816.54
7.4.40.0100.00716.37
7.4.00.0000.01615.08
7.3.330.0000.00513.07
7.3.320.0000.00512.99
7.3.310.0030.00315.97
7.3.300.0030.00316.23
7.3.290.0030.00316.03
7.3.280.0090.01016.19
7.3.260.0100.00916.21
7.3.240.0110.00816.38
7.3.230.0090.00616.58
7.3.210.0060.00916.21
7.3.200.0060.01016.56
7.3.190.0150.00616.38
7.3.180.0080.00816.43
7.3.170.0120.00916.50
7.3.160.0070.01416.38
7.3.120.0070.00717.15
7.3.110.0030.00917.15
7.3.100.0060.00617.15
7.3.90.0060.00617.15
7.3.80.0050.00417.15
7.3.70.0060.01017.15
7.3.60.0040.01117.15
7.3.50.0030.01317.15
7.3.40.0070.00717.15
7.3.30.0070.00717.15
7.3.20.0460.00916.03
7.3.10.1070.00415.86
7.3.00.0460.00315.89
7.2.330.0060.01316.69
7.2.320.0120.01116.58
7.2.310.0060.00916.30
7.2.300.0060.01216.52
7.2.290.0110.01016.65
7.2.240.0040.00817.15
7.2.230.0100.00717.15
7.2.220.0000.01017.15
7.2.210.0000.01117.15
7.2.200.0100.00317.15
7.2.190.0000.01017.15
7.2.180.0070.01117.15
7.2.170.0070.00417.15
7.2.160.0040.00717.15
7.2.150.0590.00916.05
7.2.140.0560.01316.07
7.2.130.0500.00816.04
7.2.120.0440.00616.07
7.2.110.0410.00316.11
7.2.100.0450.01015.93
7.2.90.0460.00716.13
7.2.80.0360.00815.94
7.2.70.0380.01216.00
7.2.60.0350.00316.05
7.2.50.0350.00916.01
7.2.40.0400.00815.86
7.2.30.0310.00815.95
7.2.20.0380.00716.04
7.2.10.0490.00316.05
7.2.00.0550.00815.97
7.1.330.0000.01717.15
7.1.320.0030.00917.15
7.1.310.0030.01017.15
7.1.300.0100.00317.15
7.1.290.0080.00817.15
7.1.280.0060.00617.15
7.1.270.0000.01317.15
7.1.260.0060.01017.15
7.1.250.0430.00815.53

preferences:
12.92 ms | 406 KiB | 5 Q