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($end_loop_regex,$endfor_str,$arr,PREG_OFFSET_CAPTURE); //$string = $arr[0][0][0]; $start_tag = strrpos($arr[0][0],'{'); print_r($arr); echo substr($arr[0][0],0,$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.0090.01216.50
8.3.50.0100.00622.13
8.3.40.0140.00918.88
8.3.30.0110.00419.04
8.3.20.0050.00320.33
8.3.10.0040.00423.66
8.3.00.0050.00319.51
8.2.180.0150.00716.75
8.2.170.0080.00822.96
8.2.160.0080.00620.35
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0140.00026.16
8.2.120.0050.00322.12
8.2.110.0060.00322.21
8.2.100.0040.00818.03
8.2.90.0030.00619.20
8.2.80.0050.00318.04
8.2.70.0040.00717.75
8.2.60.0040.00419.78
8.2.50.0060.00318.07
8.2.40.0040.00419.91
8.2.30.0050.00319.89
8.2.20.0040.00417.93
8.2.10.0070.00018.03
8.2.00.0050.00517.71
8.1.280.0160.00325.92
8.1.270.0000.00823.82
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00023.75
8.1.230.0060.00619.15
8.1.220.0050.00317.74
8.1.210.0000.00818.77
8.1.200.0000.00917.36
8.1.190.0000.00917.41
8.1.180.0060.00618.10
8.1.170.0030.00518.48
8.1.160.0100.00021.89
8.1.150.0040.00418.61
8.1.140.0040.00417.61
8.1.130.0000.00817.86
8.1.120.0030.00517.45
8.1.110.0040.00417.42
8.1.100.0050.00217.55
8.1.90.0040.00417.51
8.1.80.0040.00417.61
8.1.70.0030.00317.39
8.1.60.0060.00317.63
8.1.50.0050.00317.50
8.1.40.0050.00317.66
8.1.30.0040.00417.70
8.1.20.0040.00417.57
8.1.10.0020.00517.60
8.1.00.0050.00317.68
8.0.300.0000.00820.71
8.0.290.0080.00017.18
8.0.280.0000.00718.46
8.0.270.0000.00717.30
8.0.260.0000.00617.28
8.0.250.0000.00717.14
8.0.240.0030.00317.07
8.0.230.0000.00717.01
8.0.220.0070.00016.95
8.0.210.0050.00417.01
8.0.200.0050.00316.97
8.0.190.0040.00417.00
8.0.180.0040.00417.04
8.0.170.0060.00317.00
8.0.160.0000.00716.83
8.0.150.0040.00416.76
8.0.140.0000.00716.95
8.0.130.0050.00013.45
8.0.120.0040.00417.00
8.0.110.0000.00816.98
8.0.100.0070.00016.87
8.0.90.0040.00416.96
8.0.80.0110.01116.98
8.0.70.0070.00016.88
8.0.60.0000.00817.04
8.0.50.0040.00417.04
8.0.30.0150.00517.17
8.0.20.0070.01617.40
8.0.10.0000.00817.21
8.0.00.0080.00916.69
7.4.330.0060.00015.11
7.4.320.0000.00616.65
7.4.300.0060.00016.76
7.4.290.0050.00516.79
7.4.280.0060.00316.70
7.4.270.0000.00716.66
7.4.260.0000.00716.56
7.4.250.0030.00616.74
7.4.240.0040.00316.67
7.4.230.0040.00416.78
7.4.220.0160.00716.81
7.4.210.0060.00916.70
7.4.200.0040.00416.87
7.4.190.0000.00816.52
7.4.160.0060.00916.55
7.4.150.0110.01117.40
7.4.140.0100.00917.86
7.4.130.0120.00516.60
7.4.120.0130.00516.61
7.4.110.0100.01316.81
7.4.100.0090.01216.58
7.4.90.0140.00316.57
7.4.80.0060.01219.39
7.4.70.0000.01616.61
7.4.60.0100.00616.63
7.4.50.0000.00416.48
7.4.40.0110.00722.77
7.4.30.0150.00616.70
7.4.00.0000.01015.03
7.3.330.0030.00313.27
7.3.320.0030.00313.29
7.3.310.0000.00716.21
7.3.300.0070.00016.32
7.3.290.0070.01416.46
7.3.280.0060.01116.41
7.3.270.0130.00317.40
7.3.260.0110.01116.45
7.3.250.0060.01116.37
7.3.240.0080.01016.42
7.3.230.0190.00316.45
7.3.210.0070.01016.39
7.3.200.0060.01619.39
7.3.190.0090.00916.33
7.3.180.0060.01016.74
7.3.170.0060.00916.33
7.3.160.0090.00916.79
7.3.120.0030.01315.30
7.2.330.0140.00316.85
7.2.320.0110.00616.82
7.2.310.0090.00916.71
7.2.300.0070.01016.73
7.2.290.0100.00716.63
7.2.80.0090.00616.78
7.2.60.0060.00617.05
7.1.200.0000.00715.96
7.1.70.0030.00517.43
7.1.60.0060.01319.46
7.1.50.0030.01717.19
7.1.00.0030.07322.50
7.0.200.0030.00716.69
7.0.140.0070.07322.04
7.0.60.0070.07319.88
7.0.50.0030.06017.88
7.0.40.0100.08020.17
7.0.30.0200.04720.27
7.0.20.0230.07720.34
7.0.10.0070.08020.26
7.0.00.0100.05720.13
5.6.280.0000.07321.09
5.6.210.0100.05020.50
5.6.200.0100.03318.23
5.6.190.0000.04720.41
5.6.180.0230.08020.77
5.6.170.0270.07720.50
5.6.160.0070.08720.70
5.6.150.0000.06018.27
5.6.140.0070.05018.27
5.6.130.0130.08018.18
5.6.120.0100.05321.13
5.6.110.0200.06020.97
5.6.100.0000.06020.97
5.6.90.0070.08321.09
5.6.80.0070.08720.38
5.6.70.3570.03720.32
5.5.350.0330.07320.32
5.5.340.0100.06317.98
5.5.330.0070.08320.43
5.5.320.0270.04320.30
5.5.310.0170.05020.31
5.5.300.0030.03717.94
5.5.290.0070.08017.98
5.5.280.0030.08720.88
5.5.270.0130.08020.88
5.5.260.0000.05020.87
5.5.250.0100.05020.67
5.5.240.0270.07320.26
5.4.450.0930.05319.65
5.4.440.0630.06319.46
5.4.430.0100.05719.56
5.4.420.0630.06319.58
5.4.410.0170.04719.56
5.4.400.0830.05719.24
5.4.390.0830.05318.84
5.4.380.0400.05718.66
5.4.370.0330.07318.56
5.4.360.0430.05318.76
5.4.350.0370.05018.63
5.4.340.0400.05018.71
5.4.320.0070.03612.48
5.4.310.0110.03612.48
5.4.300.0080.03812.48
5.4.290.0100.03912.47
5.4.280.0060.04912.37
5.4.270.0100.04412.37
5.4.260.0090.06112.37
5.4.250.0050.08412.37
5.4.240.0100.05112.37
5.4.230.0090.04712.36
5.4.220.0130.04512.36
5.4.210.0120.04812.36
5.4.200.0110.06812.36
5.4.190.0130.05912.36
5.4.180.0130.05312.36
5.4.170.0100.04912.37
5.4.160.0040.05912.36
5.4.150.0150.06812.36
5.4.140.0130.04912.04
5.4.130.0120.05712.03
5.4.120.0240.07811.99
5.4.110.0120.04411.99
5.4.100.0100.04611.99
5.4.90.0110.06611.99
5.4.80.0120.06111.99
5.4.70.0140.06611.98
5.4.60.0110.03911.98
5.4.50.0090.04511.98
5.4.40.0070.05911.97
5.4.30.0090.05011.97
5.4.20.0160.06611.97
5.4.10.0120.07111.97
5.4.00.0100.07111.46
5.3.290.0050.04112.80
5.3.280.0160.06212.71
5.3.270.0090.05512.72
5.3.260.0140.08212.72
5.3.250.0070.05412.71
5.3.240.0110.04212.72
5.3.230.0060.04012.71
5.3.220.0070.03912.68
5.3.210.0060.04312.68
5.3.200.0090.04912.68
5.3.190.0160.05512.67
5.3.180.0130.07412.67
5.3.170.0080.06612.67
5.3.160.0150.07212.68
5.3.150.0100.05312.67
5.3.140.0070.05212.66
5.3.130.0080.05012.66
5.3.120.0070.04212.66
5.3.110.0080.04712.66
5.3.100.0070.04912.12
5.3.90.0090.05812.10
5.3.80.0070.04812.09
5.3.70.0100.04612.09
5.3.60.0060.06212.08
5.3.50.0090.05312.02
5.3.40.0110.06812.02
5.3.30.0090.05311.98
5.3.20.0080.05111.76
5.3.10.0100.07111.73
5.3.00.0050.05311.71
5.2.170.0070.0449.22
5.2.160.0100.0399.22
5.2.150.0080.0539.21
5.2.140.0080.0379.21
5.2.130.0060.0379.17
5.2.120.0060.0299.17
5.2.110.0090.0409.18
5.2.100.0040.0569.18
5.2.90.0120.0519.18
5.2.80.0040.0359.17
5.2.70.0070.0359.17
5.2.60.0070.0329.13
5.2.50.0080.0309.09
5.2.40.0030.0329.08
5.2.30.0080.0309.05
5.2.20.0120.0329.05
5.2.10.0130.0438.93
5.2.00.0100.0388.79
5.1.60.0110.0548.08
5.1.50.0090.0348.07
5.1.40.0050.0288.06
5.1.30.0060.0298.41
5.1.20.0060.0288.43
5.1.10.0040.0298.16
5.1.00.0080.0288.14
5.0.50.0070.0196.63
5.0.40.0050.0216.49
5.0.30.0040.0356.30
5.0.20.0050.0226.27
5.0.10.0060.0226.25
5.0.00.0060.0326.25
4.4.90.0050.0164.78
4.4.80.0060.0154.75
4.4.70.0040.0174.75
4.4.60.0030.0174.76
4.4.50.0040.0174.77
4.4.40.0040.0264.71
4.4.30.0040.0294.76
4.4.20.0060.0254.85
4.4.10.0040.0264.85
4.4.00.0080.0344.76
4.3.110.0050.0174.67
4.3.100.0020.0184.66
4.3.90.0050.0314.64
4.3.80.0060.0304.59
4.3.70.0040.0214.63
4.3.60.0040.0214.63
4.3.50.0090.0294.63
4.3.40.0080.0364.54
4.3.30.0060.0233.29
4.3.20.0070.0433.27
4.3.10.0000.0263.23
4.3.00.0130.03310.54

preferences:
45.39 ms | 401 KiB | 5 Q