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][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.0090.00616.75
8.3.50.0110.01121.99
8.3.40.0260.00718.80
8.3.30.0090.00618.91
8.3.20.0050.00220.29
8.3.10.0080.00023.70
8.3.00.0090.00019.38
8.2.180.0110.00416.75
8.2.170.0090.00622.96
8.2.160.0100.00320.29
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0130.00726.16
8.2.120.0000.00822.09
8.2.110.0060.00322.33
8.2.100.0050.00518.03
8.2.90.0000.00819.22
8.2.80.0040.00418.05
8.2.70.0030.00617.88
8.2.60.0040.00419.78
8.2.50.0080.00018.07
8.2.40.0000.00820.10
8.2.30.0080.00019.94
8.2.20.0000.00817.98
8.2.10.0040.00418.08
8.2.00.0070.00317.90
8.1.280.0130.00325.92
8.1.270.0000.00823.93
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0100.00723.92
8.1.230.0070.00319.04
8.1.220.0080.00017.74
8.1.210.0060.00318.77
8.1.200.0060.00317.21
8.1.190.0040.00417.50
8.1.180.0030.00718.10
8.1.170.0060.00318.57
8.1.160.0050.00522.05
8.1.150.0040.00418.73
8.1.140.0040.00417.61
8.1.130.0030.00317.90
8.1.120.0000.00717.57
8.1.110.0040.00417.60
8.1.100.0030.00517.54
8.1.90.0000.00817.47
8.1.80.0000.00717.52
8.1.70.0000.00717.43
8.1.60.0030.00517.68
8.1.50.0000.00817.61
8.1.40.0070.00017.63
8.1.30.0050.00317.58
8.1.20.0040.00417.75
8.1.10.0080.00017.59
8.1.00.0000.00717.64
8.0.300.0070.00018.77
8.0.290.0030.00517.04
8.0.280.0070.00018.42
8.0.270.0030.00317.30
8.0.260.0030.00317.30
8.0.250.0070.00017.16
8.0.240.0030.00317.06
8.0.230.0000.00716.99
8.0.220.0030.00317.12
8.0.210.0080.00017.03
8.0.200.0030.00317.00
8.0.190.0030.00617.08
8.0.180.0000.00717.12
8.0.170.0000.00816.98
8.0.160.0000.00717.04
8.0.150.0070.00016.98
8.0.140.0000.00917.02
8.0.130.0030.00313.45
8.0.120.0050.00317.00
8.0.110.0050.00317.03
8.0.100.0020.00516.93
8.0.90.0000.00817.13
8.0.80.0040.01217.04
8.0.70.0000.00716.93
8.0.60.0000.00716.98
8.0.50.0000.00717.12
8.0.30.0100.00817.25
8.0.20.0120.00717.49
8.0.10.0040.00417.07
8.0.00.0120.00616.82
7.4.330.0050.00015.11
7.4.320.0030.00316.62
7.4.300.0040.00416.68
7.4.290.0050.00316.80
7.4.280.0090.00016.76
7.4.270.0040.00416.79
7.4.260.0030.00316.55
7.4.250.0000.00916.65
7.4.240.0020.00616.74
7.4.230.0040.00316.68
7.4.220.0150.00716.79
7.4.210.0050.00916.72
7.4.200.0040.00416.79
7.4.190.0000.00816.81
7.4.160.0060.01016.91
7.4.150.0190.00317.40
7.4.140.0100.01017.86
7.4.130.0080.00816.64
7.4.120.0090.00916.83
7.4.110.0110.00716.67
7.4.100.0100.00716.69
7.4.90.0110.00716.77
7.4.80.0120.00619.39
7.4.70.0130.00316.90
7.4.60.0120.00916.81
7.4.50.0000.00816.56
7.4.40.0090.00622.77
7.4.30.0060.00916.71
7.4.00.0080.00915.21
7.3.330.0000.00513.35
7.3.320.0030.00313.36
7.3.310.0080.00016.57
7.3.300.0070.00016.50
7.3.290.0000.01416.60
7.3.280.0130.00516.63
7.3.270.0100.00717.40
7.3.260.0090.00816.71
7.3.250.0120.00516.55
7.3.240.0060.01216.50
7.3.230.0100.01016.59
7.3.210.0060.01116.86
7.3.200.0130.01019.39
7.3.190.0110.00616.55
7.3.180.0090.00916.53
7.3.170.0120.00616.72
7.3.160.0110.01116.66
7.3.120.0080.00815.06
7.3.110.0050.01115.22
7.3.100.0070.00714.70
7.3.90.0070.00515.02
7.3.80.0040.00715.02
7.3.70.0060.00915.07
7.3.60.0030.01014.95
7.3.50.0080.00714.89
7.3.40.0090.00815.02
7.3.30.0070.00614.97
7.3.20.0040.01216.94
7.3.10.0050.01116.82
7.3.00.0060.00816.79
7.2.330.0060.01216.80
7.2.320.0130.00316.79
7.2.310.0070.01116.63
7.2.300.0100.00616.63
7.2.290.0090.00816.54
7.2.250.0100.00615.43
7.2.240.0020.01314.98
7.2.230.0020.01215.05
7.2.220.0030.00815.30
7.2.210.0060.00715.05
7.2.200.0070.00715.27
7.2.190.0080.00915.22
7.2.180.0090.00815.27
7.2.170.0040.01414.98
7.2.160.0060.00614.88
7.2.150.0100.00316.96
7.2.140.0070.00717.07
7.2.130.0070.00317.15
7.2.120.0070.00716.96
7.2.110.0100.00316.96
7.2.100.0090.00416.93
7.2.90.0060.00716.90
7.2.80.0050.01016.93
7.2.70.0060.00817.19
7.2.60.0060.00617.04
7.2.50.0070.00217.08
7.2.40.0080.00517.24
7.2.30.0100.00416.89
7.2.20.0030.00717.00
7.2.10.0060.00716.80
7.2.00.0060.00717.86
7.1.330.0060.00816.09
7.1.320.0060.00615.95
7.1.310.0060.00616.15
7.1.300.0070.00616.00
7.1.290.0080.00816.09
7.1.280.0050.00615.76
7.1.270.0100.00315.86
7.1.260.0090.00515.88
7.1.250.0080.00515.98
7.1.100.0030.00818.62
7.1.70.0070.00017.40
7.1.60.0150.00719.46
7.1.50.0100.01016.99
7.1.00.0030.07722.30
7.0.200.0040.00416.88
7.0.140.0100.06722.00
7.0.60.0070.07719.92
7.0.50.0000.04317.98
7.0.40.0130.07720.11
7.0.30.0470.05720.14
7.0.20.0200.08320.16
7.0.10.0200.07320.18
7.0.00.0100.08320.24
5.6.280.0100.06720.99
5.6.210.0100.07020.64
5.6.200.0130.05318.14
5.6.190.0070.07720.39
5.6.180.0270.04020.61
5.6.170.0230.03320.61
5.6.160.0100.06020.54
5.6.150.0100.04318.25
5.6.140.0030.04318.14
5.6.130.0070.07718.17
5.6.120.0070.05321.11
5.6.110.0130.08721.00
5.6.100.0030.09020.97
5.6.90.0100.06321.09
5.6.80.0030.08020.43
5.6.70.4330.04320.50
5.5.350.0200.07720.43
5.5.340.0130.03018.03
5.5.330.0070.08020.40
5.5.320.0300.07720.32
5.5.310.0200.04020.26
5.5.300.0100.08018.06
5.5.290.0100.07717.99
5.5.280.0070.08320.77
5.5.270.0200.07320.79
5.5.260.0070.07320.63
5.5.250.0000.09320.54
5.5.240.0170.04320.25
5.4.450.0730.06719.48
5.4.440.0730.06019.31
5.4.430.0700.06319.33
5.4.420.0700.06019.56
5.4.410.0800.06019.33
5.4.400.0800.05019.16
5.4.390.0700.05718.87
5.4.380.0230.06318.53
5.4.370.0400.05718.48
5.4.360.0230.05318.46
5.4.350.0300.06318.71
5.4.340.0330.05318.59
5.4.320.0090.03712.48
5.4.310.0030.04912.47
5.4.300.0070.03712.48
5.4.290.0090.06012.47
5.4.280.0080.07112.37
5.4.270.0070.05412.37
5.4.260.0200.07212.37
5.4.250.0080.05312.37
5.4.240.0080.05312.37
5.4.230.0120.06812.36
5.4.220.0130.06012.36
5.4.210.0160.09512.36
5.4.200.0120.09012.36
5.4.190.0110.08212.36
5.4.180.0300.07512.36
5.4.170.0160.07712.37
5.4.160.0140.07012.37
5.4.150.0070.03812.36
5.4.140.0070.06312.04
5.4.130.0220.11612.04
5.4.120.0170.07511.99
5.4.110.0330.10111.98
5.4.100.0200.08911.99
5.4.90.0150.07411.98
5.4.80.0260.09611.99
5.4.70.0150.07411.98
5.4.60.0120.07011.98
5.4.50.0090.05711.98
5.4.40.0180.07411.98
5.4.30.0110.04711.97
5.4.20.0110.05111.97
5.4.10.0110.06511.97
5.4.00.0070.04811.46
5.3.290.0070.04312.80
5.3.280.0200.05512.71
5.3.270.0080.04612.72
5.3.260.0210.06712.72
5.3.250.0150.06112.71
5.3.240.0160.07512.72
5.3.230.0100.04912.71
5.3.220.0140.07912.68
5.3.210.0130.07412.68
5.3.200.0100.08112.68
5.3.190.0050.05112.67
5.3.180.0110.05012.67
5.3.170.0220.08612.67
5.3.160.0090.05912.67
5.3.150.0050.06612.67
5.3.140.0090.06212.66
5.3.130.0090.06812.66
5.3.120.0050.05712.66
5.3.110.0090.04412.66
5.3.100.0080.04412.12
5.3.90.0090.04112.10
5.3.80.0050.04612.09
5.3.70.0120.04412.09
5.3.60.0120.05812.08
5.3.50.0090.06512.02
5.3.40.0200.09012.02
5.3.30.0140.07611.98
5.3.20.0090.07211.76
5.3.10.0150.07511.73
5.3.00.0140.07811.71
5.2.170.0050.0479.22
5.2.160.0240.0829.21
5.2.150.0170.0569.22
5.2.140.0080.0699.21
5.2.130.0110.0459.17
5.2.120.0070.0439.17
5.2.110.0100.0709.18
5.2.100.0080.0549.18
5.2.90.0140.0509.18
5.2.80.0130.0709.17
5.2.70.0090.0439.17
5.2.60.0080.0419.13
5.2.50.0110.0389.09
5.2.40.0120.0469.08
5.2.30.0110.0399.05
5.2.20.0110.0389.04
5.2.10.0060.0518.94
5.2.00.0090.0698.79
5.1.60.0070.0538.08
5.1.50.0070.0258.08
5.1.40.0080.0288.05
5.1.30.0070.0318.41
5.1.20.0070.0288.43
5.1.10.0040.0448.16
5.1.00.0050.0348.14
5.0.50.0130.0516.63
5.0.40.0060.0226.49
5.0.30.0040.0346.30
5.0.20.0070.0196.27
5.0.10.0050.0276.25
5.0.00.0070.0346.24
4.4.90.0160.0724.78
4.4.80.0100.0304.76
4.4.70.0040.0224.75
4.4.60.0120.0344.75
4.4.50.0070.0374.77
4.4.40.0090.0504.71
4.4.30.0060.0334.76
4.4.20.0070.0414.84
4.4.10.0040.0324.85
4.4.00.0070.0314.76
4.3.110.0060.0234.67
4.3.100.0050.0234.66
4.3.90.0090.0154.63
4.3.80.0060.0334.59
4.3.70.0060.0214.63
4.3.60.0050.0214.63
4.3.50.0070.0334.63
4.3.40.0080.0374.54
4.3.30.0060.0213.29
4.3.20.0050.0223.26
4.3.10.0070.0213.22
4.3.00.0230.02010.54

preferences:
41.11 ms | 401 KiB | 5 Q