3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings[] = 'foo<p> <br> </p>'; $strings[] = 'foo<p> <br> </p>'; $strings[] = 'foo<p><br><br> </p>'; $strings[] = 'foo<p> <br> </p>'; foreach($strings as $string){ // \s* matches any number of whitespace characters (" ", \t, \n, etc) // (?:...)+ matches one or more (without capturing the group) // $ forces match to only be made at the end of the string $string = preg_replace("/(?:<p>\s*(?:<br>\s*)+<\/p>\s*)+$/", "", $string); echo $string."\n---\n"; }

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.0160.00316.88
8.3.50.0120.00522.11
8.3.40.0100.01019.09
8.3.30.0070.01319.04
8.3.20.0070.01120.36
8.3.10.0040.01121.73
8.3.00.0040.00417.88
8.2.180.0170.00318.42
8.2.170.0110.00422.96
8.2.160.0060.01320.47
8.2.150.0030.00624.18
8.2.140.0050.00324.66
8.2.130.0140.00426.16
8.2.120.0180.00021.11
8.2.110.0060.00322.20
8.2.100.0090.00317.84
8.2.90.0060.00319.17
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0040.00817.93
8.2.50.0030.01018.07
8.2.40.0050.00318.16
8.2.30.0000.00818.03
8.2.20.0040.00417.91
8.2.10.0000.00818.20
8.2.00.0040.00417.93
8.1.280.0070.01525.92
8.1.270.0130.00623.96
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0070.00323.96
8.1.230.0080.00319.29
8.1.220.0060.00317.79
8.1.210.0030.00518.77
8.1.200.0030.00617.48
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0040.00418.74
8.1.160.0050.00221.96
8.1.150.0030.00518.81
8.1.140.0030.00717.59
8.1.130.0030.00317.77
8.1.120.0030.00517.55
8.1.110.0040.00417.58
8.1.100.0080.00017.55
8.1.90.0040.00317.63
8.1.80.0030.00317.61
8.1.70.0050.00317.46
8.1.60.0040.00417.72
8.1.50.0080.00017.63
8.1.40.0000.00817.56
8.1.30.0040.00417.80
8.1.20.0050.00317.80
8.1.10.0070.00017.67
8.1.00.0030.00517.62
8.0.300.0000.00718.77
8.0.290.0030.00616.88
8.0.280.0020.00518.39
8.0.270.0000.00817.20
8.0.260.0040.00417.34
8.0.250.0070.00016.96
8.0.240.0030.00617.07
8.0.230.0040.00416.99
8.0.220.0030.00317.04
8.0.210.0000.00817.05
8.0.200.0030.00317.03
8.0.190.0030.00517.00
8.0.180.0050.00317.08
8.0.170.0050.00316.98
8.0.160.0030.00517.09
8.0.150.0000.00716.88
8.0.140.0050.00216.92
8.0.130.0000.00513.45
8.0.120.0030.00717.05
8.0.110.0040.00417.07
8.0.100.0040.00416.87
8.0.90.0080.00016.91
8.0.80.0120.00917.07
8.0.70.0040.00416.83
8.0.60.0000.00716.98
8.0.50.0000.00816.88
8.0.30.0090.00917.13
8.0.20.0110.01317.47
8.0.10.0040.00417.15
8.0.00.0090.01116.82
7.4.330.0050.00015.02
7.4.320.0030.00316.58
7.4.300.0030.00316.73
7.4.290.0030.00316.70
7.4.280.0040.00416.65
7.4.270.0090.00016.86
7.4.260.0070.00016.71
7.4.250.0030.00516.64
7.4.240.0060.00216.75
7.4.230.0030.00316.72
7.4.220.0190.00616.85
7.4.210.0150.00016.71
7.4.200.0030.00316.61
7.4.160.0110.00416.71
7.4.150.0110.00917.40
7.4.140.0100.00717.86
7.4.130.0060.01016.76
7.4.120.0080.00916.66
7.4.110.0080.00816.63
7.4.100.0070.01116.75
7.4.90.0070.01016.45
7.4.80.0140.00419.39
7.4.70.0170.00716.62
7.4.60.0060.01016.62
7.4.50.0030.00616.65
7.4.40.0090.00916.67
7.4.30.0060.01116.62
7.4.00.0070.01014.83
7.3.330.0030.00313.17
7.3.320.0030.00313.24
7.3.310.0000.00716.36
7.3.300.0070.00016.45
7.3.290.0130.00716.47
7.3.280.0050.01116.44
7.3.270.0140.00617.40
7.3.260.0070.01016.58
7.3.250.0090.00816.36
7.3.240.0140.00416.56
7.3.230.0050.01416.48
7.3.210.0090.00916.46
7.3.200.0030.01919.39
7.3.190.0100.00616.71
7.3.180.0100.00616.57
7.3.170.0130.00316.87
7.3.160.0100.00716.43
7.3.10.0100.00717.00
7.3.00.0130.00316.76
7.2.330.0110.00716.81
7.2.320.0120.01216.93
7.2.310.0030.01416.88
7.2.300.0070.01016.69
7.2.290.0080.00816.99
7.2.130.0140.00317.16
7.2.120.0150.00416.91
7.2.110.0070.00716.97
7.2.100.0000.01217.21
7.2.90.0080.00417.29
7.2.80.0030.01217.22
7.2.70.0000.01417.25
7.2.60.0120.00317.05
7.2.50.0090.00317.06
7.2.40.0030.01217.16
7.2.30.0060.00617.12
7.2.20.0060.00617.08
7.2.10.0060.00917.00
7.2.00.0070.00518.56
7.1.250.0100.00315.68
7.1.100.0090.00318.15
7.1.70.0060.00317.42
7.1.60.0070.01119.40
7.1.50.0100.01317.12
7.1.00.0000.08022.56
7.0.200.0030.00716.74
7.0.140.0070.06322.04
7.0.60.0070.08319.94
7.0.50.0070.08717.94
7.0.40.0100.04020.43
7.0.30.0430.07720.16
7.0.20.0300.07720.21
7.0.10.0070.04320.19
7.0.00.0000.06020.10
5.6.280.0000.07720.86
5.6.210.0070.04720.48
5.6.200.0130.04318.11
5.6.190.0000.05020.39
5.6.180.0270.05720.41
5.6.170.0330.07320.44
5.6.160.0100.08020.51
5.6.150.0100.06318.15
5.6.140.0030.07318.18
5.6.130.0030.09018.11
5.6.120.0170.07021.02
5.6.110.0070.07020.86
5.6.100.0170.07320.97
5.6.90.0100.08021.10
5.6.80.0000.05020.53
5.5.350.0470.06320.34
5.5.340.0070.06017.95
5.5.330.0130.07720.23
5.5.320.0230.06020.51
5.5.310.0330.03720.50
5.5.300.0130.05017.91
5.5.290.0100.06017.95
5.5.280.0130.07720.97
5.5.270.0100.05320.86
5.5.260.0030.06720.93
5.5.250.0130.04720.79
5.5.240.0200.04320.25
5.4.450.0400.04019.26
5.4.440.0070.05019.13
5.4.430.0370.04019.20
5.4.420.0100.05319.45
5.4.410.0400.04318.97
5.4.400.0230.04319.13
5.4.390.0270.04019.23
5.4.380.0270.06318.59
5.4.370.0430.04018.71
5.4.360.0370.04718.56
5.4.350.0270.06718.49
5.4.340.0330.05018.46
5.4.320.0080.03612.46
5.4.310.0050.04412.45
5.4.300.0080.03512.46
5.4.290.0050.04112.45
5.4.280.0040.03812.35
5.4.270.0100.05312.35
5.4.260.0100.04812.35
5.4.250.0020.04212.35
5.4.240.0080.03712.35
5.4.230.0040.03912.34
5.4.220.0070.03512.34
5.4.210.0080.03412.34
5.4.200.0070.03612.34
5.4.190.0060.03512.34
5.4.180.0050.03612.34
5.4.170.0080.03612.35
5.4.160.0070.05012.34
5.4.150.0050.04112.34
5.4.140.0060.04812.02
5.4.130.0080.04612.01
5.4.120.0110.03611.97
5.4.110.0080.03611.96
5.4.100.0060.03911.96
5.4.90.0050.03811.96
5.4.80.0090.03411.97
5.4.70.0050.03511.96
5.4.60.0070.04611.96
5.4.50.0090.03511.96
5.4.40.0050.03411.95
5.4.30.0070.03511.95
5.4.20.0070.04711.95
5.4.10.0060.03711.95
5.4.00.0060.03511.44
5.3.290.0030.04412.80
5.3.280.0070.03712.71
5.3.270.0040.04112.72
5.3.260.0090.03512.72
5.3.250.0070.03812.72
5.3.240.0090.03712.72
5.3.230.0090.04312.71
5.3.220.0120.03612.68
5.3.210.0070.05112.68
5.3.200.0080.03512.68
5.3.190.0040.04212.68
5.3.180.0070.03612.68
5.3.170.0110.03912.67
5.3.160.0060.04112.68
5.3.150.0090.03712.67
5.3.140.0090.04712.66
5.3.130.0090.04212.66
5.3.120.0050.04312.66
5.3.110.0080.04312.66
5.3.100.0090.04312.12
5.3.90.0160.08212.08
5.3.80.0150.04412.08
5.3.70.0050.04012.08
5.3.60.0070.04712.06
5.3.50.0110.05612.00
5.3.40.0070.04512.00
5.3.30.0080.04011.95
5.3.20.0060.04411.73
5.3.10.0080.03911.70
5.3.00.0060.04011.69
5.2.170.0080.0339.19
5.2.160.0050.0489.19
5.2.150.0040.0339.19
5.2.140.0070.0319.18
5.2.130.0060.0299.14
5.2.120.0080.0309.14
5.2.110.0040.0309.16
5.2.100.0070.0299.15
5.2.90.0050.0319.15
5.2.80.0070.0309.14
5.2.70.0040.0319.15
5.2.60.0090.0289.10
5.2.50.0060.0399.07
5.2.40.0110.0249.05
5.2.30.0090.0279.04
5.2.20.0060.0389.02
5.2.10.0060.0288.92
5.2.00.0070.0278.78
5.1.60.0040.0278.06
5.1.50.0040.0258.06
5.1.40.0040.0278.04
5.1.30.0040.0308.39
5.1.20.0050.0308.41
5.1.10.0070.0268.14
5.1.00.0090.0298.14
5.0.50.0050.0206.61
5.0.40.0090.0166.48
5.0.30.0060.0326.29
5.0.20.0040.0276.26
5.0.10.0050.0296.24
5.0.00.0040.0366.23
4.4.90.0070.0194.78
4.4.80.0060.0174.75
4.4.70.0040.0204.75
4.4.60.0000.0204.75
4.4.50.0040.0164.77
4.4.40.0050.0254.71
4.4.30.0030.0194.76
4.4.20.0020.0174.85
4.4.10.0050.0214.85
4.4.00.0050.0294.76
4.3.110.0050.0254.66
4.3.100.0040.0204.67
4.3.90.0080.0164.63
4.3.80.0040.0264.59
4.3.70.0040.0144.63
4.3.60.0060.0154.63
4.3.50.0060.0214.62
4.3.40.0040.0334.54
4.3.30.0040.0193.28
4.3.20.0020.0213.26
4.3.10.0070.0153.22
4.3.00.0000.02015.90

preferences:
46.78 ms | 401 KiB | 5 Q