3v4l.org

run code in 300+ PHP versions simultaneously
<?php $exp = '/[\s\S]*\{%[\s\S]*for[\s\S]*ad[\s\S]*in[\s\S]*ads[\s\S]*%\}/'; $string = "{% for ad in ads %} sdfksjf {% for ad in ads %} sdfksjf2 {% for ad in ads %} sdfksjf3"; /* function str_lreplace($search, $replace, $subject) { return preg_replace('~(.*)' . preg_quote($search, '~') . '~', '$1' . $replace, $subject, 1); } echo str_lreplace($exp,'',$string); */ $end_loop_regex = '/[\.\s\S]*\{%[\s\S]*endfor[\s\S]*%\}/'; $endfor_str = "{% endfor%}1 {% endfor %}2 {%endfor%}3 {% endfor%}4"; //$arr = preg_split($end_loop_regex,$endfor_str,0,PREG_SPLIT_OFFSET_CAPTURE); preg_match_all($end_loop_regex,$endfor_str,$arr,PREG_OFFSET_CAPTURE); $string = $arr[0]; //$start_tag = strrpos($arr[0][0],'{'); print_r($arr); echo $string; //$last_end_for_pos = strrpos($return,'{% endfor %}'); //$return = substr($return,0,$last_end_for_pos);

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.0110.01116.62
8.3.50.0160.00321.99
8.3.40.0100.01019.09
8.3.30.0030.01219.09
8.3.20.0000.00720.20
8.3.10.0030.00623.71
8.3.00.0060.00319.51
8.2.180.0130.00316.63
8.2.170.0070.00722.96
8.2.160.0130.00720.35
8.2.150.0040.00424.18
8.2.140.0050.00224.66
8.2.130.0060.00326.16
8.2.120.0040.00422.38
8.2.110.0040.00421.96
8.2.100.0110.00018.16
8.2.90.0000.00719.39
8.2.80.0060.00318.16
8.2.70.0060.00317.63
8.2.60.0040.00419.78
8.2.50.0080.00018.07
8.2.40.0000.00920.20
8.2.30.0030.00619.94
8.2.20.0080.00017.84
8.2.10.0000.00819.96
8.2.00.0070.00417.95
8.1.280.0070.01025.92
8.1.270.0040.00423.89
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0050.00523.83
8.1.230.0110.00019.02
8.1.220.0000.00917.74
8.1.210.0050.00318.77
8.1.200.0040.00717.48
8.1.190.0050.00317.28
8.1.180.0050.00518.10
8.1.170.0030.00518.71
8.1.160.0030.00721.90
8.1.150.0040.00418.83
8.1.140.0000.00717.46
8.1.130.0070.00017.80
8.1.120.0050.00217.50
8.1.110.0050.00317.60
8.1.100.0000.00717.54
8.1.90.0000.00717.58
8.1.80.0050.00217.48
8.1.70.0000.00717.48
8.1.60.0050.00317.59
8.1.50.0040.00417.62
8.1.40.0070.00017.71
8.1.30.0030.00517.73
8.1.20.0040.00417.78
8.1.10.0000.00717.75
8.1.00.0080.00017.69
8.0.300.0040.00420.64
8.0.290.0040.00417.18
8.0.280.0030.00318.36
8.0.270.0030.00317.30
8.0.260.0030.00317.29
8.0.250.0040.00417.24
8.0.240.0060.00017.16
8.0.230.0040.00317.10
8.0.220.0000.00717.09
8.0.210.0100.00016.89
8.0.200.0040.00417.02
8.0.190.0040.00417.13
8.0.180.0040.00417.08
8.0.170.0040.00416.96
8.0.160.0000.00817.12
8.0.150.0070.00017.04
8.0.140.0080.00017.07
8.0.130.0030.00313.48
8.0.120.0000.00816.98
8.0.110.0040.00416.95
8.0.100.0000.00717.10
8.0.90.0030.00516.95
8.0.80.0060.00916.94
8.0.70.0000.00717.02
8.0.60.0000.00817.08
8.0.50.0040.00416.88
8.0.30.0050.01617.49
8.0.20.0100.01117.40
8.0.10.0000.00717.18
8.0.00.0100.00717.08
7.4.330.0020.00215.01
7.4.320.0060.00016.64
7.4.300.0000.00816.71
7.4.290.0040.00416.73
7.4.280.0050.00516.67
7.4.270.0040.00416.57
7.4.260.0010.00616.76
7.4.250.0000.00916.78
7.4.240.0020.00616.63
7.4.230.0070.00016.56
7.4.220.0090.01216.76
7.4.210.0050.00916.70
7.4.200.0070.00016.75
7.4.190.0000.00916.83
7.4.160.0120.00416.84
7.4.150.0040.01417.40
7.4.140.0050.01317.86
7.4.130.0080.00816.57
7.4.120.0090.01116.81
7.4.110.0160.00716.79
7.4.100.0030.01516.69
7.4.90.0120.00616.56
7.4.80.0060.01019.39
7.4.70.0110.00716.75
7.4.60.0040.01216.57
7.4.50.0060.00316.73
7.4.40.0050.01022.77
7.4.30.0030.01216.90
7.4.00.0060.01015.31
7.3.330.0000.00513.33
7.3.320.0030.00313.38
7.3.310.0000.00716.55
7.3.300.0080.00016.48
7.3.290.0100.00616.49
7.3.280.0070.00916.48
7.3.270.0160.00917.40
7.3.260.0060.01616.59
7.3.250.0130.00516.48
7.3.240.0090.01316.47
7.3.230.0060.01116.92
7.3.210.0140.00416.48
7.3.200.0090.00919.39
7.3.190.0090.00916.39
7.3.180.0110.00716.75
7.3.170.0100.00616.46
7.3.160.0170.00716.75
7.3.120.0100.00714.98
7.2.330.0110.00616.84
7.2.320.0100.00716.95
7.2.310.0120.00616.75
7.2.300.0100.00716.68
7.2.290.0140.00316.83
7.1.70.0040.00717.07
7.1.60.0090.00919.46
7.1.50.0070.01517.20
7.1.00.0100.06722.30
7.0.200.0030.00616.89
7.0.140.0030.07022.10
7.0.60.0070.08719.83
7.0.50.0130.07317.91
7.0.40.0070.07020.14
7.0.30.0170.05020.25
7.0.20.0070.05020.22
7.0.10.0100.08720.10
7.0.00.0030.04320.32
5.6.280.0100.06721.01
5.6.210.0100.07320.62
5.6.200.0000.04318.22
5.6.190.0330.03020.55
5.6.180.0230.07720.77
5.6.170.0270.06720.57
5.6.160.0030.07320.52
5.6.150.0070.04018.19
5.6.140.0130.07318.18
5.6.130.0030.04318.21
5.6.120.0070.05720.98
5.6.110.0130.08021.10
5.6.100.0100.07721.06
5.6.90.0070.06321.07
5.6.80.0130.06020.36
5.6.70.3300.04020.38
5.5.350.0270.06720.33
5.5.340.0100.05717.95
5.5.330.0030.08020.29
5.5.320.0200.04720.36
5.5.310.0230.04720.26
5.5.300.0030.04017.94
5.5.290.0130.08018.09
5.5.280.0100.04720.65
5.5.270.0070.08020.83
5.5.260.0070.04020.79
5.5.250.0100.06720.54
5.5.240.0300.07020.34
5.4.450.0730.06719.38
5.4.440.0670.06019.30
5.4.430.0670.06019.44
5.4.420.0900.06019.59
5.4.410.0600.05719.25
5.4.400.0600.04319.30
5.4.390.0770.05319.27
5.4.380.0230.05718.55
5.4.370.0270.05718.50
5.4.360.0300.05318.79
5.4.350.0270.06018.84
5.4.340.0300.05318.75
5.4.320.0060.03712.48
5.4.310.0080.03712.48
5.4.300.0060.03812.48
5.4.290.0170.08412.47
5.4.280.0180.06512.37
5.4.270.0070.07012.37
5.4.260.0130.05812.37
5.4.250.0090.06412.37
5.4.240.0170.06912.37
5.4.230.0170.05612.36
5.4.220.0090.06812.36
5.4.210.0080.06212.36
5.4.200.0100.06012.36
5.4.190.0150.06712.36
5.4.180.0130.06512.36
5.4.170.0080.05712.37
5.4.160.0050.05712.36
5.4.150.0160.07212.36
5.4.140.0080.05612.05
5.4.130.0110.05612.04
5.4.120.0110.05811.99
5.4.110.0140.06711.99
5.4.100.0090.03811.99
5.4.90.0090.05211.99
5.4.80.0070.05611.99
5.4.70.0140.04911.98
5.4.60.0090.05111.98
5.4.50.0140.04011.98
5.4.40.0070.05011.97
5.4.30.0140.07611.97
5.4.20.0080.05111.96
5.4.10.0120.05511.97
5.4.00.0100.05311.46
5.3.290.0070.03812.80
5.3.280.0130.07012.71
5.3.270.0240.10412.72
5.3.260.0210.07012.71
5.3.250.0070.04512.72
5.3.240.0150.07212.71
5.3.230.0100.03812.71
5.3.220.0090.03712.68
5.3.210.0060.04312.68
5.3.200.0100.04012.68
5.3.190.0090.06612.68
5.3.180.0140.05612.67
5.3.170.0100.05912.67
5.3.160.0130.08712.68
5.3.150.0130.06012.68
5.3.140.0160.07112.66
5.3.130.0150.05512.66
5.3.120.0130.05712.66
5.3.110.0110.05912.66
5.3.100.0090.05712.11
5.3.90.0050.06212.10
5.3.80.0160.05012.09
5.3.70.0130.05012.09
5.3.60.0080.04912.07
5.3.50.0080.04912.02
5.3.40.0090.05812.02
5.3.30.0110.05111.98
5.3.20.0080.05711.76
5.3.10.0080.04611.73
5.3.00.0080.06511.71
5.2.170.0170.0549.21
5.2.160.0060.0589.22
5.2.150.0150.0739.21
5.2.140.0100.0649.21
5.2.130.0090.0479.17
5.2.120.0140.0449.18
5.2.110.0240.0839.18
5.2.100.0100.0489.18
5.2.90.0130.0509.18
5.2.80.0130.0549.17
5.2.70.0100.0739.18
5.2.60.0060.0489.13
5.2.50.0070.0519.09
5.2.40.0050.0419.07
5.2.30.0080.0439.05
5.2.20.0050.0479.04
5.2.10.0070.0408.94
5.2.00.0160.0728.79
5.1.60.0070.0638.08
5.1.50.0090.0388.07
5.1.40.0080.0528.06
5.1.30.0060.0418.41
5.1.20.0070.0418.43
5.1.10.0070.0518.16
5.1.00.0060.0418.15
5.0.50.0070.0326.63
5.0.40.0120.0516.49
5.0.30.0060.0516.30
5.0.20.0100.0306.27
5.0.10.0180.0566.25
5.0.00.0160.0546.24
4.4.90.0170.1024.78
4.4.80.0120.0354.76
4.4.70.0060.0254.75
4.4.60.0120.0454.75
4.4.50.0060.0244.77
4.4.40.0040.0404.71
4.4.30.0140.0464.76
4.4.20.0160.0424.84
4.4.10.0030.0314.85
4.4.00.0070.0474.76
4.3.110.0070.0334.67
4.3.100.0070.0284.67
4.3.90.0040.0244.63
4.3.80.0120.0524.59
4.3.70.0090.0334.63
4.3.60.0050.0214.63
4.3.50.0060.0144.63
4.3.40.0050.0264.54
4.3.30.0030.0173.30
4.3.20.0020.0183.25
4.3.10.0030.0173.22
4.3.00.0400.02710.54

preferences:
38.84 ms | 401 KiB | 5 Q