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); //$string = $arr[0][0][0]; $start_tag = strrpos($arr[0],'{'); //print_r($arr); //echo substr($arr[0],0,$start_tag); $string = "{% for ad in ads %} <a href=\"{{ad.url}}\">{{ad.name}}</a> <ul> <li>Ad: <a href=\"{{ad.url}}\">{{ad.name}}({{ad.id}})</a></li> <li>Client: {{ad.client_name}} ({{ad.client_id}})</li> <li>Price: {{ad.price}}</li> <li>Expected Revenue: {{ad.expected_revenue}}</li> <li>Display Url: {{ad.display_url}}</li> <li>Headline: {{ad.headline}}</li> <li>Body: {{ad.body}}</li> <li>Logo: <img src=\"{{ad.logo.url}}\"/></li> <li>Type: {{ad.type}}</li> {% if ad.conditions|length %} <li>Conditions: </li> <ul> {% for condition in ad.conditions %} <li>{{condition.conditiontype.name}} {{condition.operator}} {{condition.value}} </li> {% endfor %} </ul> {% endif %} </ul> {% endfor %}"; echo preg_replace($exp,'',$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.0130.00716.75
8.3.50.0070.01122.03
8.3.40.0100.01019.10
8.3.30.0060.00919.14
8.3.20.0050.00220.30
8.3.10.0040.00423.66
8.3.00.0090.00019.51
8.2.180.0160.00616.88
8.2.170.0070.00722.96
8.2.160.0150.00320.43
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00422.25
8.2.110.0070.00320.58
8.2.100.0000.01019.88
8.2.90.0040.00418.28
8.2.80.0090.00018.03
8.2.70.0050.00318.00
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0060.00320.07
8.2.30.0030.00620.02
8.2.20.0080.00018.00
8.2.10.0000.00818.11
8.2.00.0040.00717.80
8.1.280.0190.00325.92
8.1.270.0040.00424.02
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0080.00022.14
8.1.230.0090.00321.08
8.1.220.0030.00517.91
8.1.210.0080.00019.02
8.1.200.0000.01017.60
8.1.190.0050.00317.54
8.1.180.0120.00018.10
8.1.170.0030.00720.39
8.1.160.0080.00022.06
8.1.150.0040.00418.76
8.1.140.0040.00417.57
8.1.130.0030.00517.90
8.1.120.0050.00317.66
8.1.110.0070.00017.57
8.1.100.0040.00417.54
8.1.90.0070.00017.61
8.1.80.0040.00417.57
8.1.70.0070.00017.39
8.1.60.0000.00817.74
8.1.50.0030.00617.54
8.1.40.0000.00817.72
8.1.30.0030.00617.74
8.1.20.0050.00317.84
8.1.10.0050.00317.73
8.1.00.0000.00717.68
8.0.300.0060.00320.40
8.0.290.0050.00217.30
8.0.280.0040.00418.56
8.0.270.0030.00317.29
8.0.260.0030.00317.36
8.0.250.0030.00317.13
8.0.240.0040.00417.01
8.0.230.0070.00017.08
8.0.220.0030.00316.96
8.0.210.0030.00617.04
8.0.200.0040.00417.04
8.0.190.0030.00617.00
8.0.180.0000.00817.09
8.0.170.0040.00417.04
8.0.160.0000.00716.98
8.0.150.0040.00417.00
8.0.140.0040.00416.87
8.0.130.0030.00313.41
8.0.120.0080.00016.90
8.0.110.0040.00417.06
8.0.100.0000.00716.84
8.0.90.0000.00716.82
8.0.80.0050.01817.00
8.0.70.0040.00416.93
8.0.60.0000.00716.98
8.0.50.0000.00716.98
8.0.30.0110.01117.32
8.0.20.0070.01117.45
8.0.10.0030.00516.97
8.0.00.0130.00616.99
7.4.330.0060.00015.04
7.4.320.0060.00016.81
7.4.300.0030.00316.75
7.4.290.0090.00316.71
7.4.280.0000.01216.77
7.4.270.0040.00416.84
7.4.260.0000.00716.72
7.4.250.0040.00416.71
7.4.240.0020.00616.69
7.4.230.0030.00316.54
7.4.220.0090.00916.71
7.4.210.0090.00816.73
7.4.200.0000.00716.64
7.4.190.0030.00516.92
7.4.160.0080.01116.57
7.4.150.0150.00317.40
7.4.140.0070.01517.86
7.4.130.0130.00516.65
7.4.120.0070.01016.79
7.4.110.0070.01616.91
7.4.100.0070.01416.77
7.4.90.0130.00316.76
7.4.80.0110.00719.39
7.4.70.0130.00316.70
7.4.60.0040.01216.81
7.4.50.0000.00416.59
7.4.40.0050.00822.77
7.4.30.0130.00316.71
7.4.00.0060.01014.99
7.3.330.0030.00313.13
7.3.320.0030.00313.09
7.3.310.0050.00316.42
7.3.300.0030.00316.38
7.3.290.0060.00916.37
7.3.280.0100.01116.40
7.3.270.0110.00817.40
7.3.260.0110.01116.86
7.3.250.0090.01116.61
7.3.240.0030.01416.67
7.3.230.0130.00316.76
7.3.210.0160.00716.85
7.3.200.0030.01619.39
7.3.190.0130.01016.61
7.3.180.0030.01316.66
7.3.170.0100.00616.82
7.3.160.0110.00616.57
7.3.120.0100.00314.86
7.2.330.0070.01016.76
7.2.320.0100.00716.80
7.2.310.0090.01216.71
7.2.300.0090.00916.95
7.2.290.0160.00016.98
7.2.60.0030.00617.18
7.2.00.0000.01219.51
7.1.200.0090.00015.94
7.1.100.0080.00818.44
7.1.70.0040.01117.07
7.1.60.0030.00919.46
7.1.50.0060.02216.82
7.1.00.0000.07722.32
7.0.200.0040.01417.06
7.0.140.0000.07722.09
7.0.60.0000.07719.94
7.0.50.0100.07717.96
7.0.40.0230.06320.26
7.0.30.0230.04320.23
7.0.20.0200.04320.27
7.0.10.0100.08020.22
7.0.00.0030.05320.17
5.6.280.0100.07021.01
5.6.210.0000.08720.62
5.6.200.0030.04018.15
5.6.190.0100.03720.41
5.6.180.0270.06720.45
5.6.170.0170.06020.50
5.6.160.0100.08020.52
5.6.150.0000.08318.12
5.6.140.0100.06718.17
5.6.130.0070.04018.11
5.6.120.0030.05021.14
5.6.110.0070.05021.04
5.6.100.0070.07720.96
5.6.90.0100.08021.01
5.6.80.0170.07320.28
5.6.70.2570.04020.37
5.5.350.0300.07020.33
5.5.340.0030.08717.95
5.5.330.0130.07020.21
5.5.320.0170.04320.51
5.5.310.0200.04720.15
5.5.300.0030.04017.91
5.5.290.0130.04717.91
5.5.280.0070.06720.84
5.5.270.0170.07320.64
5.5.260.0070.04020.86
5.5.250.0030.05320.61
5.5.240.0230.06320.27
5.4.450.0800.05319.48
5.4.440.0700.05319.10
5.4.430.0570.06319.42
5.4.420.0830.05319.44
5.4.410.0570.05718.99
5.4.400.0100.05018.91
5.4.390.0670.06019.24
5.4.380.0330.05018.59
5.4.370.0300.06318.52
5.4.360.0400.05718.46
5.4.350.0270.06018.78
5.4.340.0600.06318.59
5.4.320.0050.03812.46
5.4.310.0090.03512.46
5.4.300.0050.03712.46
5.4.290.0080.05512.45
5.4.280.0080.05712.34
5.4.270.0040.05812.34
5.4.260.0190.07612.34
5.4.250.0090.05512.34
5.4.240.0070.05612.34
5.4.230.0140.07412.33
5.4.220.0110.04612.33
5.4.210.0100.04612.34
5.4.200.0080.06212.34
5.4.190.0080.05812.33
5.4.180.0100.05712.33
5.4.170.0090.05112.34
5.4.160.0070.05012.34
5.4.150.0100.04812.33
5.4.140.0060.05412.02
5.4.130.0090.04812.01
5.4.120.0060.04611.96
5.4.110.0150.04011.96
5.4.100.0110.04611.96
5.4.90.0070.05011.96
5.4.80.0070.05611.96
5.4.70.0100.03211.96
5.4.60.0060.03511.96
5.4.50.0070.03411.96
5.4.40.0030.03911.94
5.4.30.0040.03811.94
5.4.20.0080.03311.94
5.4.10.0090.04711.94
5.4.00.0090.06411.43
5.3.290.0040.04112.80
5.3.280.0110.04812.70
5.3.270.0100.05212.73
5.3.260.0130.05112.72
5.3.250.0100.05012.72
5.3.240.0100.05012.72
5.3.230.0080.05312.71
5.3.220.0090.05812.68
5.3.210.0110.06012.68
5.3.200.0080.05412.68
5.3.190.0100.05312.68
5.3.180.0090.05312.67
5.3.170.0100.05812.67
5.3.160.0040.06312.67
5.3.150.0140.05712.68
5.3.140.0120.05012.66
5.3.130.0080.06012.65
5.3.120.0130.05512.66
5.3.110.0070.05812.65
5.3.100.0120.03812.12
5.3.90.0050.04412.08
5.3.80.0070.03512.07
5.3.70.0090.03412.07
5.3.60.0060.03712.06
5.3.50.0090.05012.00
5.3.40.0070.04012.00
5.3.30.0060.04811.96
5.3.20.0110.04111.74
5.3.10.0090.04411.70
5.3.00.0120.05211.69
5.2.170.0120.0339.20
5.2.160.0070.0419.20
5.2.150.0070.0449.20
5.2.140.0080.0419.19
5.2.130.0090.0379.15
5.2.120.0060.0399.15
5.2.110.0030.0359.16
5.2.100.0080.0279.15
5.2.90.0040.0319.15
5.2.80.0050.0319.14
5.2.70.0070.0329.15
5.2.60.0060.0309.10
5.2.50.0040.0319.07
5.2.40.0030.0329.05
5.2.30.0050.0309.02
5.2.20.0040.0339.02
5.2.10.0040.0318.92
5.2.00.0060.0288.78
5.1.60.0040.0248.07
5.1.50.0050.0248.06
5.1.40.0030.0288.04
5.1.30.0040.0288.39
5.1.20.0090.0318.41
5.1.10.0110.0398.14
5.1.00.0060.0338.15
5.0.50.0040.0286.61
5.0.40.0010.0296.48
5.0.30.0090.0436.29
5.0.20.0050.0236.26
5.0.10.0030.0226.24
5.0.00.0030.0316.23
4.4.90.0030.0164.78
4.4.80.0030.0164.75
4.4.70.0030.0214.76
4.4.60.0040.0214.75
4.4.50.0070.0194.77
4.4.40.0090.0444.71
4.4.30.0060.0174.76
4.4.20.0000.0264.84
4.4.10.0060.0214.85
4.4.00.0070.0844.76
4.3.110.0040.0214.67
4.3.100.0040.0204.66
4.3.90.0050.0184.64
4.3.80.0030.0304.59
4.3.70.0020.0174.63
4.3.60.0030.0154.63
4.3.50.0040.0154.63
4.3.40.0050.0294.53
4.3.30.0020.0223.29
4.3.20.0020.0213.26
4.3.10.0030.0173.22
4.3.00.0300.01310.54

preferences:
44.74 ms | 401 KiB | 5 Q