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); $start_tag = strrpos($arr[0][0],'{'); print_r($arr); echo $start_tag; //$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.0040.01116.48
8.3.50.0090.01022.07
8.3.40.0130.00618.86
8.3.30.0110.00419.18
8.3.20.0000.00719.96
8.3.10.0040.00423.66
8.3.00.0070.00419.63
8.2.180.0040.01116.50
8.2.170.0090.00622.96
8.2.160.0090.00920.27
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0080.00026.16
8.2.120.0030.00619.49
8.2.110.0090.00022.26
8.2.100.0090.00318.03
8.2.90.0000.00919.27
8.2.80.0030.00517.97
8.2.70.0060.00317.88
8.2.60.0000.01017.92
8.2.50.0040.00418.07
8.2.40.0050.00319.89
8.2.30.0050.00319.97
8.2.20.0050.00317.89
8.2.10.0040.00417.96
8.2.00.0030.00617.88
8.1.280.0210.00025.92
8.1.270.0040.00424.04
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0060.00323.79
8.1.230.0110.00019.20
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0000.00817.30
8.1.180.0100.00418.10
8.1.170.0000.00918.78
8.1.160.0040.00721.91
8.1.150.0000.00718.64
8.1.140.0040.00417.54
8.1.130.0000.00717.86
8.1.120.0030.00617.58
8.1.110.0040.00417.48
8.1.100.0000.00717.59
8.1.90.0000.00717.53
8.1.80.0040.00417.56
8.1.70.0000.00717.48
8.1.60.0030.00617.73
8.1.50.0050.00317.60
8.1.40.0050.00217.60
8.1.30.0040.00417.61
8.1.20.0040.00417.80
8.1.10.0000.00817.63
8.1.00.0040.00417.54
8.0.300.0040.00419.28
8.0.290.0000.00717.05
8.0.280.0000.00718.36
8.0.270.0070.00017.14
8.0.260.0080.00017.16
8.0.250.0020.00517.01
8.0.240.0070.00017.14
8.0.230.0000.00817.14
8.0.220.0030.00316.95
8.0.210.0090.00017.04
8.0.200.0000.00717.09
8.0.190.0000.00817.10
8.0.180.0050.00217.11
8.0.170.0000.00817.08
8.0.160.0040.00316.88
8.0.150.0000.00717.07
8.0.140.0070.00017.04
8.0.130.0000.00713.43
8.0.120.0040.00416.97
8.0.110.0040.00416.89
8.0.100.0040.00417.07
8.0.90.0000.00717.10
8.0.80.0030.01316.98
8.0.70.0050.00216.84
8.0.60.0040.00416.91
8.0.50.0000.00717.00
8.0.30.0190.00017.11
8.0.20.0070.01717.40
8.0.10.0070.00017.26
8.0.00.0070.01017.10
7.4.330.0020.00215.00
7.4.320.0000.00716.75
7.4.300.0030.00316.61
7.4.290.0040.00416.77
7.4.280.0050.00516.70
7.4.270.0000.00716.71
7.4.260.0070.00016.65
7.4.250.0040.00416.61
7.4.240.0000.00716.65
7.4.230.0000.00716.64
7.4.220.0040.01816.69
7.4.210.0040.01016.72
7.4.200.0070.00016.75
7.4.190.0030.00416.75
7.4.160.0170.00716.52
7.4.150.0150.00317.40
7.4.140.0090.00917.86
7.4.130.0070.00916.69
7.4.120.0080.00916.71
7.4.110.0100.00716.87
7.4.100.0110.01116.65
7.4.90.0100.01016.70
7.4.80.0110.00719.39
7.4.70.0080.01116.76
7.4.60.0120.00616.57
7.4.50.0020.00216.55
7.4.40.0000.01422.77
7.4.30.0070.01016.76
7.4.00.0100.00715.33
7.3.330.0020.00313.41
7.3.320.0050.00013.20
7.3.310.0030.00516.40
7.3.300.0030.00316.34
7.3.290.0060.01016.50
7.3.280.0100.00816.53
7.3.270.0000.01817.40
7.3.260.0090.00916.48
7.3.250.0110.00816.56
7.3.240.0060.01016.49
7.3.230.0100.00716.59
7.3.210.0070.01016.72
7.3.200.0090.01119.39
7.3.190.0090.00816.58
7.3.180.0100.00616.66
7.3.170.0060.01516.52
7.3.160.0080.00816.49
7.3.120.0070.01015.04
7.2.330.0060.01216.91
7.2.320.0070.01116.84
7.2.310.0070.01016.79
7.2.300.0070.01116.82
7.2.290.0120.00916.66
7.2.60.0120.00317.10
7.2.00.0110.00719.66
7.1.200.0120.00315.72
7.1.100.0120.00818.05
7.1.70.0030.01017.40
7.1.60.0070.01419.46
7.1.50.0070.01416.99
7.1.00.0070.07322.59
7.0.200.0050.00516.77
7.0.140.0070.06322.13
7.0.60.0000.04720.02
7.0.50.0170.07317.92
7.0.40.0170.04320.14
7.0.30.0300.08020.23
7.0.20.0270.08320.32
7.0.10.0370.07320.08
7.0.00.0070.03720.18
5.6.280.0030.07320.86
5.6.210.0100.05320.75
5.6.200.0070.07018.23
5.6.190.0070.05720.61
5.6.180.0330.06320.48
5.6.170.0170.04020.54
5.6.160.0130.08320.46
5.6.150.0000.04318.28
5.6.140.0070.03718.18
5.6.130.0000.08718.28
5.6.120.0100.06720.99
5.6.110.0070.07320.99
5.6.100.0070.08321.03
5.6.90.0070.07020.99
5.6.80.0070.04320.40
5.6.70.4030.04720.36
5.5.350.0100.07020.43
5.5.340.0130.07717.98
5.5.330.0100.06320.21
5.5.320.0270.03720.30
5.5.310.0200.06720.29
5.5.300.0030.05718.06
5.5.290.0000.08717.98
5.5.280.0170.07320.73
5.5.270.0030.08320.75
5.5.260.0070.04020.64
5.5.250.0070.07720.57
5.5.240.0030.07720.18
5.4.450.0570.06319.16
5.4.440.0800.05719.56
5.4.430.0100.05319.16
5.4.420.0530.05719.18
5.4.410.0730.06019.49
5.4.400.0700.05319.24
5.4.390.0070.05719.01
5.4.380.0300.05018.52
5.4.370.0400.05318.71
5.4.360.0400.04318.46
5.4.350.0300.08318.50
5.4.340.0230.06318.61
5.4.320.0070.03512.48
5.4.310.0040.04012.48
5.4.300.0020.03912.48
5.4.290.0110.06012.47
5.4.280.0090.05612.37
5.4.270.0100.06312.37
5.4.260.0110.06712.37
5.4.250.0120.08812.37
5.4.240.0090.06412.37
5.4.230.0160.05212.36
5.4.220.0070.05812.36
5.4.210.0090.05112.36
5.4.200.0090.05812.36
5.4.190.0110.05712.36
5.4.180.0090.05812.36
5.4.170.0080.05912.37
5.4.160.0150.07212.37
5.4.150.0140.07512.36
5.4.140.0120.05812.05
5.4.130.0190.07612.03
5.4.120.0230.07711.99
5.4.110.0190.08411.99
5.4.100.0050.08011.98
5.4.90.0100.05511.98
5.4.80.0080.04811.98
5.4.70.0080.03611.98
5.4.60.0060.03811.98
5.4.50.0100.03511.98
5.4.40.0060.03911.97
5.4.30.0200.10011.97
5.4.20.0040.04111.97
5.4.10.0090.03711.97
5.4.00.0180.07111.46
5.3.290.0050.04412.80
5.3.280.0060.04412.71
5.3.270.0100.04212.72
5.3.260.0090.04212.72
5.3.250.0090.04712.71
5.3.240.0080.04312.72
5.3.230.0070.04512.71
5.3.220.0090.04112.68
5.3.210.0120.03712.68
5.3.200.0030.04512.68
5.3.190.0070.04112.68
5.3.180.0100.04412.67
5.3.170.0100.03712.67
5.3.160.0100.04812.67
5.3.150.0080.04012.67
5.3.140.0040.04312.66
5.3.130.0070.04312.66
5.3.120.0070.04312.66
5.3.110.0100.05412.66
5.3.100.0120.05712.11
5.3.90.0080.04512.10
5.3.80.0130.07212.09
5.3.70.0180.06012.09
5.3.60.0160.05712.07
5.3.50.0270.09812.02
5.3.40.0070.05212.02
5.3.30.0070.04911.98
5.3.20.0070.05611.76
5.3.10.0080.04811.73
5.3.00.0160.08311.72
5.2.170.0130.0829.22
5.2.160.0190.0599.21
5.2.150.0280.0929.21
5.2.140.0130.0629.21
5.2.130.0170.0709.18
5.2.120.0120.0679.17
5.2.110.0060.0509.18
5.2.100.0120.0559.18
5.2.90.0130.0639.18
5.2.80.0090.0669.17
5.2.70.0140.0629.18
5.2.60.0070.0449.13
5.2.50.0070.0459.09
5.2.40.0150.0579.07
5.2.30.0120.0589.06
5.2.20.0080.0439.04
5.2.10.0040.0528.93
5.2.00.0060.0508.80
5.1.60.0140.0588.08
5.1.50.0110.0468.07
5.1.40.0060.0428.05
5.1.30.0120.0538.41
5.1.20.0120.0678.43
5.1.10.0070.0628.15
5.1.00.0140.0638.14
5.0.50.0090.0556.63
5.0.40.0110.0356.50
5.0.30.0060.0626.30
5.0.20.0080.0306.27
5.0.10.0120.0306.25
5.0.00.0060.0486.24
4.4.90.0070.0254.78
4.4.80.0030.0284.76
4.4.70.0050.0284.75
4.4.60.0050.0344.75
4.4.50.0050.0274.77
4.4.40.0070.0584.71
4.4.30.0060.0434.76
4.4.20.0080.0474.85
4.4.10.0060.0494.85
4.4.00.0080.0494.76
4.3.110.0090.0414.67
4.3.100.0050.0374.67
4.3.90.0150.0344.64
4.3.80.0050.0404.59
4.3.70.0050.0244.63
4.3.60.0040.0234.63
4.3.50.0040.0314.63
4.3.40.0060.0374.54
4.3.30.0050.0393.29
4.3.20.0010.0233.26
4.3.10.0040.0253.22
4.3.00.0170.03310.54

preferences:
45.9 ms | 401 KiB | 5 Q