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.70.0100.01316.88
8.3.60.0030.01416.73
8.3.50.0070.00821.95
8.3.40.0110.01119.04
8.3.30.0000.01419.13
8.3.20.0080.00020.34
8.3.10.0080.00023.53
8.3.00.0000.00819.25
8.2.180.0040.01916.63
8.2.170.0120.00622.96
8.2.160.0060.00920.60
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0080.00026.16
8.2.120.0040.00422.38
8.2.110.0030.00622.38
8.2.100.0060.00618.03
8.2.90.0000.00919.33
8.2.80.0000.00817.97
8.2.70.0030.00617.88
8.2.60.0000.00817.93
8.2.50.0060.00318.07
8.2.40.0000.00820.20
8.2.30.0040.00419.93
8.2.20.0000.00717.95
8.2.10.0040.00418.20
8.2.00.0050.00517.94
8.1.280.0140.00725.92
8.1.270.0080.00023.84
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0060.00323.79
8.1.230.0040.00819.32
8.1.220.0060.00317.91
8.1.210.0080.00018.77
8.1.200.0000.00817.48
8.1.190.0000.00817.53
8.1.180.0080.00318.10
8.1.170.0060.00318.71
8.1.160.0040.00722.06
8.1.150.0040.00418.84
8.1.140.0060.00317.63
8.1.130.0030.00317.83
8.1.120.0000.00717.63
8.1.110.0030.00517.55
8.1.100.0000.00717.57
8.1.90.0080.00017.57
8.1.80.0080.00017.63
8.1.70.0030.00317.39
8.1.60.0030.00517.73
8.1.50.0000.00917.58
8.1.40.0040.00417.65
8.1.30.0030.00717.76
8.1.20.0040.00417.86
8.1.10.0030.00517.73
8.1.00.0030.00617.73
8.0.300.0000.00718.77
8.0.290.0030.00617.29
8.0.280.0030.00318.53
8.0.270.0000.00717.37
8.0.260.0060.00017.27
8.0.250.0000.00717.12
8.0.240.0000.00716.98
8.0.230.0030.00316.97
8.0.220.0000.00817.01
8.0.210.0060.00316.91
8.0.200.0040.00417.09
8.0.190.0000.00917.13
8.0.180.0000.01016.95
8.0.170.0000.00817.06
8.0.160.0040.00416.89
8.0.150.0000.00716.92
8.0.140.0040.00417.02
8.0.130.0060.00013.43
8.0.120.0040.00417.09
8.0.110.0040.00417.05
8.0.100.0000.00717.09
8.0.90.0000.00716.95
8.0.80.0090.01316.97
8.0.70.0070.00017.13
8.0.60.0040.00416.84
8.0.50.0040.00417.04
8.0.30.0080.01017.30
8.0.20.0130.00717.40
8.0.10.0040.00416.95
8.0.00.0130.00517.06
7.4.330.0000.00615.09
7.4.320.0000.00716.71
7.4.300.0030.00316.79
7.4.290.0030.00616.61
7.4.280.0070.00416.61
7.4.270.0040.00416.81
7.4.260.0000.00716.68
7.4.250.0050.00316.56
7.4.240.0050.00216.82
7.4.230.0050.00316.54
7.4.220.0090.01016.73
7.4.210.0060.01016.75
7.4.200.0000.00716.78
7.4.190.0000.00716.93
7.4.160.0080.00816.70
7.4.150.0000.01717.40
7.4.140.0070.01017.86
7.4.130.0110.00716.69
7.4.120.0110.00716.64
7.4.110.0150.00416.68
7.4.100.0160.00616.75
7.4.90.0130.00316.74
7.4.80.0070.01419.39
7.4.70.0080.00816.68
7.4.60.0100.01016.86
7.4.50.0040.00016.80
7.4.40.0080.00822.77
7.4.30.0120.00316.63
7.4.00.0030.00915.01
7.3.330.0030.00313.17
7.3.320.0000.00613.08
7.3.310.0070.00016.15
7.3.300.0000.00716.40
7.3.290.0130.00316.36
7.3.280.0060.01016.36
7.3.270.0060.01217.40
7.3.260.0060.01316.45
7.3.250.0100.00716.58
7.3.240.0090.00816.38
7.3.230.0040.02016.39
7.3.210.0030.01316.53
7.3.200.0140.00919.39
7.3.190.0100.00616.72
7.3.180.0070.01116.74
7.3.170.0000.01516.39
7.3.160.0090.00916.47
7.3.120.0070.00715.23
7.2.330.0110.00616.74
7.2.320.0090.00916.93
7.2.310.0170.00316.77
7.2.300.0100.00716.77
7.2.290.0060.01016.70
7.1.200.0060.00016.05
7.1.70.0060.00617.44
7.1.60.0060.00619.46
7.1.50.0160.01017.25
7.1.00.0130.06322.32
7.0.200.0030.00616.61
7.0.140.0000.07022.12
7.0.60.0100.08019.98
7.0.50.0130.07317.92
7.0.40.0070.07320.22
7.0.30.0300.08020.35
7.0.20.0270.07020.05
7.0.10.0100.04720.14
7.0.00.0170.07720.24
5.6.280.0030.07320.99
5.6.210.0030.05020.72
5.6.200.0170.06718.18
5.6.190.0070.04020.41
5.6.180.0370.07720.41
5.6.170.0230.04320.51
5.6.160.0030.04320.61
5.6.150.0030.05318.16
5.6.140.0200.07318.17
5.6.130.0070.05318.11
5.6.120.0000.04721.10
5.6.110.0230.06020.98
5.6.100.0100.03321.13
5.6.90.0170.03721.03
5.6.80.0170.06020.35
5.6.70.0070.08020.48
5.5.350.0330.07320.38
5.5.340.0130.07717.93
5.5.330.0100.03720.37
5.5.320.0200.04020.17
5.5.310.0170.04020.27
5.5.300.0030.04317.96
5.5.290.0100.06318.02
5.5.280.0130.07720.73
5.5.270.0130.07320.89
5.5.260.0070.08320.72
5.5.250.0070.08020.68
5.5.240.0270.07020.23
5.4.450.1800.04719.13
5.4.440.1970.03019.13
5.4.430.1900.03319.54
5.4.420.2070.04019.40
5.4.410.2070.03019.43
5.4.400.2070.04318.81
5.4.390.2000.04719.07
5.4.380.2200.03719.10
5.4.370.2070.04718.89
5.4.360.2130.03719.07
5.4.350.2070.04018.93
5.4.340.1830.04719.16
5.4.320.1830.04018.77
5.4.310.2070.03718.91
5.4.300.1770.04019.02
5.4.290.1930.04319.13
5.4.280.2100.05019.14
5.4.270.2030.04018.77
5.4.260.1730.03318.93
5.4.250.1800.04018.80
5.4.240.2000.03319.07
5.4.230.1830.03719.07
5.4.220.1830.03319.23
5.4.210.2030.04319.12
5.4.200.2030.03718.92
5.4.190.2030.04718.79
5.4.180.2200.04719.07
5.4.170.2070.04018.76
5.4.160.1830.03719.11
5.4.150.1930.03319.11
5.4.140.2070.04316.24
5.4.130.2130.04316.49
5.4.120.2070.03016.36
5.4.110.2030.04316.54
5.4.100.2100.04016.39
5.4.90.2000.04316.46
5.4.80.2070.03716.41
5.4.70.2130.03316.41
5.4.60.2030.04016.12
5.4.50.2030.03716.38
5.4.40.1730.04016.04
5.4.30.1870.03716.18
5.4.20.2000.04316.39
5.4.10.2030.04016.18
5.4.00.1870.03315.73
5.3.290.1930.04314.64
5.3.280.2000.04714.50
5.3.270.2070.04714.46
5.3.260.1800.04014.59
5.3.250.1870.03314.54
5.3.240.2100.05014.45
5.3.230.2200.04714.54
5.3.220.2070.03714.50
5.3.210.1930.04714.44
5.3.200.2000.02314.44
5.3.190.2070.04014.40
5.3.180.1970.05314.55
5.3.170.1830.03714.52
5.3.160.1970.04014.51
5.3.150.2100.04014.58
5.3.140.1900.03714.58
5.3.130.2230.04014.64
5.3.120.1830.04014.41
5.3.110.1900.03314.39
5.3.100.1400.04313.88
5.3.90.0070.04013.92
5.3.80.0130.03314.12
5.3.70.1270.05714.12
5.3.60.2370.04013.78
5.3.50.2000.03713.93
5.3.40.1800.03013.89
5.3.30.2030.04313.69
5.3.20.1870.03713.46
5.3.10.1830.02713.75
5.3.00.1970.05713.48
5.2.170.1200.03011.00
5.2.160.1730.03311.05
5.2.150.1530.02711.15
5.2.140.1730.03711.00
5.2.130.1770.03311.02
5.2.120.1670.03310.95
5.2.110.1730.02710.94
5.2.100.1700.04010.95
5.2.90.1530.02311.13
5.2.80.1730.04011.04
5.2.70.1730.04010.91
5.2.60.1930.03010.96
5.2.50.1770.03711.18
5.2.40.1300.03310.86
5.2.30.1170.03011.02
5.2.20.1130.03310.85
5.2.10.0800.02710.86
5.2.00.0030.03710.79
5.1.60.0030.0539.86
5.1.50.0030.03710.08
5.1.40.0630.0309.85
5.1.30.1570.03710.19
5.1.20.1270.03010.30
5.1.10.1170.02710.08
5.1.00.1400.03010.05
5.0.50.0800.0278.46
5.0.40.0670.0278.31
5.0.30.0600.0308.11
5.0.20.0630.0178.17
5.0.10.0600.0238.07
5.0.00.0600.0338.29
4.4.90.0630.0138.07
4.4.80.0870.0108.07
4.4.70.0600.0178.07
4.4.60.0700.0108.07
4.4.50.0630.0138.07
4.4.40.0530.0308.07
4.4.30.0600.0178.07
4.4.20.0570.0208.07
4.4.10.0000.0208.07
4.4.00.0000.0278.07
4.3.110.0030.0178.07
4.3.100.0030.0138.07
4.3.90.0000.0178.07
4.3.80.0000.0278.07
4.3.70.0000.0178.07
4.3.60.0130.0178.07
4.3.50.0600.0208.07
4.3.40.0530.0238.07
4.3.30.0200.0178.07
4.3.20.0230.0178.07
4.3.10.0230.0108.07
4.3.00.0300.0178.07

preferences:
59.45 ms | 401 KiB | 5 Q