3v4l.org

run code in 300+ PHP versions simultaneously
<? $data = "The cat likes to sit on the fence. He also likes to climb the tree."; $find ="/the/"; $replace ="a"; //1. replace single word Echo "$data <br>"; Echo preg_replace ($find, $replace, $data); //create arrays $find2 = array ('/the/', '/cat/'); $replace2 = array ('a', 'dog'); //2. replace with array values Echo preg_replace ($find2, $replace2, $data); //3. Replace just once Echo preg_replace ($find2, $replace2, $data, 1); //4. Keep a count of replacements $count = 0; Echo preg_replace ($find2, $replace2, $data, -1, $count); Echo "<br>You have made $count replacements"; ?>

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.0030.01016.38
8.3.50.0100.01021.99
8.3.40.0100.01018.82
8.3.30.0120.00319.05
8.3.20.0100.00020.38
8.3.10.0050.00323.70
8.3.00.0040.00719.13
8.2.180.0060.01616.38
8.2.170.0100.00322.96
8.2.160.0100.00320.57
8.2.150.0070.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0100.00322.11
8.2.110.0030.00620.35
8.2.100.0080.00417.78
8.2.90.0060.00319.11
8.2.80.0050.00317.97
8.2.70.0000.00817.50
8.2.60.0090.00017.80
8.2.50.0100.00018.07
8.2.40.0040.00419.82
8.2.30.0000.00717.95
8.2.20.0040.00417.66
8.2.10.0020.00517.85
8.2.00.0040.00417.65
8.1.280.0080.00825.92
8.1.270.0000.00823.91
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0000.00922.05
8.1.230.0080.00317.42
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0040.00417.10
8.1.190.0000.00717.39
8.1.180.0030.00618.10
8.1.170.0030.00518.55
8.1.160.0000.00721.98
8.1.150.0080.00018.43
8.1.140.0000.00817.30
8.1.130.0000.00717.75
8.1.120.0000.00717.32
8.1.110.0040.00417.38
8.1.100.0070.00017.35
8.1.90.0030.00317.33
8.1.80.0000.00717.31
8.1.70.0070.00017.29
8.1.60.0090.00017.44
8.1.50.0080.00017.39
8.1.40.0000.00717.43
8.1.30.0040.00417.30
8.1.20.0030.00517.41
8.1.10.0040.00417.44
8.1.00.0030.00617.45
8.0.300.0040.00418.77
8.0.290.0000.00816.63
8.0.280.0000.00718.38
8.0.270.0000.00717.20
8.0.260.0040.00417.11
8.0.250.0070.00016.85
8.0.240.0000.00816.70
8.0.230.0000.00816.73
8.0.220.0000.00716.77
8.0.210.0070.00016.79
8.0.200.0070.00016.86
8.0.190.0040.00416.71
8.0.180.0040.00716.82
8.0.170.0020.00516.79
8.0.160.0040.00416.73
8.0.150.0070.00016.62
8.0.140.0000.00716.71
8.0.130.0080.00013.49
8.0.120.0030.00516.74
8.0.110.0020.00516.82
8.0.100.0000.00716.76
8.0.90.0050.00216.63
8.0.80.0040.01216.73
8.0.70.0040.00416.72
8.0.60.0000.00716.63
8.0.50.0040.00416.67
8.0.30.0110.00716.98
8.0.20.0120.00617.40
8.0.10.0000.00716.89
8.0.00.0120.00916.68
7.4.330.0020.00215.00
7.4.320.0000.00616.48
7.4.300.0000.00716.47
7.4.290.0000.00816.44
7.4.280.0000.00916.39
7.4.270.0030.00316.48
7.4.260.0000.00916.40
7.4.250.0040.00416.26
7.4.240.0060.00216.41
7.4.230.0070.00016.45
7.4.220.0150.00416.50
7.4.210.0050.01016.48
7.4.200.0000.00716.39
7.4.190.0070.00016.63
7.4.160.0060.01016.09
7.4.150.0060.01117.40
7.4.140.0040.01317.86
7.4.130.0140.00516.28
7.4.120.0060.01016.41
7.4.110.0150.01016.25
7.4.100.0040.01416.53
7.4.90.0080.01516.34
7.4.80.0070.01419.39
7.4.70.0070.01016.34
7.4.60.0070.01116.33
7.4.50.0030.00616.35
7.4.40.0120.00616.39
7.4.30.0100.00716.15
7.4.00.0030.01314.81
7.3.330.0050.00013.41
7.3.320.0030.00313.34
7.3.310.0000.00816.27
7.3.300.0000.00716.01
7.3.290.0100.01016.13
7.3.280.0060.01216.17
7.3.270.0140.00517.40
7.3.260.0150.00316.29
7.3.250.0130.00616.34
7.3.240.0060.01516.39
7.3.230.0100.00716.39
7.3.210.0070.01016.36
7.3.200.0110.01119.39
7.3.190.0030.01616.03
7.3.180.0040.01116.40
7.3.170.0100.01016.27
7.3.160.0130.00316.22
7.3.120.0060.00914.86
7.2.330.0120.00716.60
7.2.320.0150.01216.56
7.2.310.0090.00916.12
7.2.300.0040.01216.63
7.2.290.0110.00716.56
7.2.00.0060.00619.61
7.1.100.0120.00018.36
7.1.70.0060.00317.32
7.1.60.0140.01119.46
7.1.50.0030.01717.05
7.1.00.0070.07322.59
7.0.200.0000.00716.92
7.0.140.0030.07721.96
7.0.60.0070.07719.93
7.0.50.0100.07717.90
7.0.40.0070.05020.00
7.0.30.0230.06020.20
7.0.20.0270.05720.03
7.0.10.0030.07320.18
7.0.00.0030.08320.31
5.6.280.0000.07720.86
5.6.210.0100.07320.52
5.6.200.0070.07318.22
5.6.190.0030.05320.77
5.6.180.0130.05720.61
5.6.170.0200.04020.48
5.6.160.0070.03720.62
5.6.150.0030.08718.14
5.6.140.0070.03718.21
5.6.130.0030.04318.09
5.6.120.0030.05021.12
5.6.110.0130.06020.98
5.6.100.0130.07721.13
5.6.90.0130.06320.98
5.6.80.0100.07020.36
5.5.350.4300.04020.42
5.5.340.0070.08317.97
5.5.330.0070.05020.57
5.5.320.0270.04320.17
5.5.310.0330.06020.27
5.5.300.0000.05717.99
5.5.290.0130.07317.91
5.5.280.0070.07320.89
5.5.270.0030.07320.75
5.5.260.0130.08020.96
5.5.250.0100.07720.61
5.5.240.0030.07720.25
5.4.450.0270.05719.64
5.4.440.0100.06319.52
5.4.430.0130.06319.52
5.4.420.0270.05319.52
5.4.410.0130.07319.11
5.4.400.0300.06318.94
5.4.390.0200.06019.26
5.4.380.0400.05718.59
5.4.370.0470.04018.71
5.4.360.0430.04018.70
5.4.350.0400.05318.58
5.4.340.0500.04318.63
5.4.320.0050.04012.45
5.4.310.0090.05012.45
5.4.300.0040.03912.46
5.4.290.0080.08112.43
5.4.280.0160.06612.33
5.4.270.0100.05012.33
5.4.260.0050.04912.33
5.4.250.0050.05212.33
5.4.240.0130.06912.33
5.4.230.0140.05512.32
5.4.220.0120.08912.32
5.4.210.0060.05812.32
5.4.200.0070.06412.32
5.4.190.0080.04312.32
5.4.180.0130.08012.32
5.4.170.0090.06012.33
5.4.160.0150.04712.32
5.4.150.0210.09012.32
5.4.140.0080.05912.00
5.4.130.0070.03912.00
5.4.120.0120.05611.95
5.4.110.0100.03811.95
5.4.100.0080.04911.95
5.4.90.0100.06411.95
5.4.80.0170.07511.95
5.4.70.0170.08511.94
5.4.60.0090.06911.95
5.4.50.0080.07911.94
5.4.40.0060.06011.93
5.4.30.0120.07011.93
5.4.20.0080.06811.93
5.4.10.0060.05711.93
5.4.00.0090.06211.42
5.3.290.0070.03812.80
5.3.280.0060.09712.71
5.3.270.0070.09012.72
5.3.260.0100.07812.72
5.3.250.0090.06312.72
5.3.240.0100.06012.72
5.3.230.0080.05412.71
5.3.220.0130.11312.68
5.3.210.0130.06112.68
5.3.200.0160.07312.68
5.3.190.0090.08212.68
5.3.180.0100.07212.67
5.3.170.0110.10612.67
5.3.160.0100.08712.67
5.3.150.0140.10312.68
5.3.140.0150.06512.66
5.3.130.0030.05212.66
5.3.120.0050.05312.66
5.3.110.0130.08312.66
5.3.100.0120.05312.12
5.3.90.0080.05612.09
5.3.80.0140.07412.07
5.3.70.0100.08012.07
5.3.60.0090.06012.07
5.3.50.0240.10012.00
5.3.40.0140.04512.00
5.3.30.0150.05111.94
5.3.20.0080.06411.72
5.3.10.0070.04211.69
5.3.00.0100.06911.67
5.2.170.0140.0599.17
5.2.160.0090.0399.18
5.2.150.0110.0679.18
5.2.140.0110.0479.17
5.2.130.0090.0499.13
5.2.120.0180.0559.13
5.2.110.0090.0599.13
5.2.100.0130.0739.13
5.2.90.0150.0609.13
5.2.80.0050.0469.13
5.2.70.0060.0449.13
5.2.60.0100.0439.08
5.2.50.0080.0459.05
5.2.40.0050.0449.03
5.2.30.0050.0769.00
5.2.20.0030.0488.99
5.2.10.0050.0438.92
5.2.00.0060.0418.78
5.1.60.0070.0328.05
5.1.50.0070.0328.05
5.1.40.0030.0378.04
5.1.30.0080.0348.39
5.1.20.0090.0418.41
5.1.10.0040.0378.13
5.1.00.0090.0428.13
5.0.50.0120.0326.61
5.0.40.0090.0426.47
5.0.30.0030.0496.29
5.0.20.0060.0406.25
5.0.10.0030.0346.24
5.0.00.0020.0486.23
4.4.90.0040.0484.78
4.4.80.0080.0404.75
4.4.70.0060.0284.75
4.4.60.0030.0344.75
4.4.50.0080.0314.77
4.4.40.0180.0824.71
4.4.30.0050.0204.76
4.4.20.0060.0454.84
4.4.10.0120.0864.85
4.4.00.0030.0354.75
4.3.110.0090.0614.67
4.3.100.0050.0204.66
4.3.90.0020.0184.63
4.3.80.0030.0344.59
4.3.70.0020.0224.63
4.3.60.0070.0254.63
4.3.50.0080.0534.63
4.3.40.0050.0504.54
4.3.30.0070.0383.28
4.3.20.0030.0363.25
4.3.10.0070.0373.22
4.3.00.0000.0237.30

preferences:
71.03 ms | 400 KiB | 5 Q