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 %}'; 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.0120.00316.75
8.3.50.0100.00822.03
8.3.40.0150.00618.99
8.3.30.0140.00019.04
8.3.20.0040.00420.33
8.3.10.0080.00023.36
8.3.00.0080.00019.13
8.2.180.0070.01418.72
8.2.170.0120.00622.96
8.2.160.0100.00320.31
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0110.00426.16
8.2.120.0000.00822.33
8.2.110.0090.00022.28
8.2.100.0040.00817.84
8.2.90.0040.00419.18
8.2.80.0050.00317.97
8.2.70.0000.00917.75
8.2.60.0080.00018.03
8.2.50.0060.00318.07
8.2.40.0030.00519.91
8.2.30.0040.00419.88
8.2.20.0000.00817.75
8.2.10.0030.00618.10
8.2.00.0070.00317.81
8.1.280.0090.00925.92
8.1.270.0060.00323.92
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00323.82
8.1.230.0050.00521.13
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0040.00417.48
8.1.190.0000.00917.53
8.1.180.0070.00418.10
8.1.170.0070.00418.71
8.1.160.0070.00322.05
8.1.150.0050.00318.68
8.1.140.0070.00017.57
8.1.130.0000.00717.84
8.1.120.0040.00417.46
8.1.110.0080.00017.61
8.1.100.0000.00717.55
8.1.90.0070.00017.62
8.1.80.0000.00717.48
8.1.70.0040.00417.59
8.1.60.0050.00517.71
8.1.50.0030.00517.67
8.1.40.0060.00317.68
8.1.30.0030.00517.64
8.1.20.0080.00017.81
8.1.10.0030.00617.77
8.1.00.0000.00817.72
8.0.300.0060.00318.77
8.0.290.0000.00717.18
8.0.280.0000.00718.45
8.0.270.0040.00417.31
8.0.260.0030.00317.31
8.0.250.0070.00017.07
8.0.240.0040.00417.10
8.0.230.0040.00417.07
8.0.220.0070.00016.98
8.0.210.0040.00416.93
8.0.200.0040.00417.06
8.0.190.0030.00517.09
8.0.180.0040.00417.13
8.0.170.0030.00517.08
8.0.160.0040.00416.98
8.0.150.0050.00316.84
8.0.140.0040.00417.01
8.0.130.0000.00513.41
8.0.120.0080.00016.88
8.0.110.0000.00716.99
8.0.100.0040.00416.90
8.0.90.0000.00817.02
8.0.80.0000.01617.00
8.0.70.0040.00417.08
8.0.60.0000.00817.02
8.0.50.0000.00717.13
8.0.30.0080.01017.35
8.0.20.0090.01117.47
8.0.10.0040.00416.99
8.0.00.0130.01016.92
7.4.330.0030.00315.11
7.4.320.0000.00616.65
7.4.300.0000.00716.80
7.4.290.0100.00016.83
7.4.280.0000.01116.72
7.4.270.0040.00416.72
7.4.260.0030.00316.71
7.4.250.0000.00816.73
7.4.240.0020.00516.78
7.4.230.0000.00716.70
7.4.220.0070.01116.82
7.4.210.0060.01016.73
7.4.200.0040.00416.79
7.4.190.0050.00316.83
7.4.160.0060.00916.85
7.4.150.0110.00717.40
7.4.140.0100.01017.86
7.4.130.0100.00716.72
7.4.120.0090.01116.73
7.4.110.0040.01416.58
7.4.100.0120.00616.60
7.4.90.0070.01016.63
7.4.80.0070.01419.39
7.4.70.0040.01416.47
7.4.60.0060.01216.52
7.4.50.0030.00316.61
7.4.40.0100.00722.77
7.4.30.0000.01716.61
7.4.10.0100.01015.18
7.4.00.0060.01015.06
7.3.330.0030.00313.20
7.3.320.0000.00613.03
7.3.310.0050.00216.37
7.3.300.0070.00016.39
7.3.290.0040.01116.54
7.3.280.0070.01216.35
7.3.270.0150.00317.40
7.3.260.0200.00416.31
7.3.250.0070.01416.57
7.3.240.0120.00616.45
7.3.230.0140.01116.77
7.3.210.0090.00916.28
7.3.200.0040.01719.39
7.3.190.0190.00316.55
7.3.180.0070.01016.34
7.3.170.0090.00616.56
7.3.160.0060.01216.48
7.3.130.0000.01914.79
7.3.120.0060.01014.93
7.3.110.0070.01414.69
7.3.100.0070.00714.96
7.3.90.0080.00414.83
7.3.80.0040.01115.13
7.3.70.0130.00314.86
7.3.60.0070.00714.99
7.3.50.0060.00914.64
7.3.40.0000.01314.94
7.3.30.0030.01014.86
7.3.20.0000.01116.64
7.3.10.0060.00916.80
7.3.00.0060.00616.67
7.2.330.0120.00816.68
7.2.320.0110.00616.83
7.2.310.0140.00416.70
7.2.300.0070.01016.74
7.2.290.0100.00616.88
7.2.260.0110.00714.88
7.2.250.0040.01515.13
7.2.240.0080.00815.04
7.2.230.0090.00914.78
7.2.220.0030.01415.40
7.2.210.0120.00014.96
7.2.200.0060.01214.98
7.2.190.0000.01515.16
7.2.180.0150.00414.96
7.2.170.0030.00714.98
7.2.160.0070.00414.99
7.2.150.0040.01116.72
7.2.140.0030.01316.98
7.2.130.0050.00816.91
7.2.120.0110.00416.97
7.2.110.0090.00416.74
7.2.100.0080.00616.94
7.2.90.0080.00816.94
7.2.80.0060.00416.83
7.2.70.0090.00417.05
7.2.60.0060.00816.94
7.2.50.0110.00517.13
7.2.40.0060.00916.91
7.2.30.0060.00717.04
7.2.20.0070.00916.82
7.2.10.0000.01216.93
7.2.00.0070.00717.92
7.1.330.0040.01215.88
7.1.320.0130.00315.96
7.1.310.0130.00315.76
7.1.300.0000.01815.80
7.1.290.0040.01115.78
7.1.280.0090.00615.77
7.1.270.0060.00615.84
7.1.260.0100.00316.10
7.1.250.0040.00515.94
7.1.240.0060.00916.10
7.1.230.0060.00615.75
7.1.220.0000.01216.06
7.1.210.0070.00415.77
7.1.200.0090.00615.75
7.1.190.0080.00416.15
7.1.180.0040.00715.95
7.1.170.0090.00915.94
7.1.160.0100.00316.12
7.1.150.0090.00016.08
7.1.140.0040.00716.02
7.1.130.0060.01015.79
7.1.120.0030.00715.95
7.1.110.0070.01015.96
7.1.100.0090.00616.96
7.1.90.0070.01016.09
7.1.80.0090.00415.74
7.1.70.0030.00716.77
7.1.60.0050.01117.62
7.1.50.0060.01516.53
7.1.40.0030.01316.18
7.1.30.0040.00716.00
7.1.20.0030.00915.72
7.1.10.0030.00915.79
7.1.00.0040.04119.12
7.0.330.0070.00415.18
7.0.320.0040.00415.23
7.0.310.0030.00715.47
7.0.300.0100.00715.68
7.0.290.0060.00615.57
7.0.280.0040.01115.25
7.0.270.0100.00615.55
7.0.260.0000.00915.42
7.0.250.0100.00315.34
7.0.240.0060.00715.61
7.0.230.0090.00615.70
7.0.220.0080.00515.48
7.0.210.0030.00715.25
7.0.200.0080.00216.25
7.0.190.0000.01215.61
7.0.180.0100.00315.67
7.0.170.0050.00515.54
7.0.160.0090.00315.54
7.0.150.0110.00415.24
7.0.140.0020.04218.87
7.0.130.0070.00715.60
7.0.120.0000.01015.52
7.0.110.0060.00915.38
7.0.100.0100.00615.68
7.0.90.0100.00715.75
7.0.80.0060.00915.23
7.0.70.0040.00415.70
7.0.60.0070.04017.67
7.0.50.0050.03316.70
7.0.40.0120.04216.79
7.0.30.0190.02416.87
7.0.20.0110.02916.85
7.0.10.0140.03316.97
7.0.00.0070.02516.80
5.6.400.0090.00614.53
5.6.390.0070.01014.31
5.6.380.0050.00514.52
5.6.370.0120.00614.40
5.6.360.0030.01214.41
5.6.350.0030.00914.58
5.6.340.0090.00014.23
5.6.330.0070.00714.40
5.6.320.0040.00414.41
5.6.310.0030.00613.93
5.6.300.0030.01014.57
5.6.290.0080.00814.52
5.6.280.0040.03917.78
5.6.270.0040.01114.09
5.6.260.0080.00814.36
5.6.250.0070.00714.30
5.6.240.0150.00014.52
5.6.230.0030.01314.21
5.6.220.0000.01714.36
5.6.210.0070.04517.29
5.6.200.0030.04016.24
5.6.190.0050.05017.27
5.6.180.0180.02317.56
5.6.170.0180.04417.44
5.6.160.0020.04917.46
5.6.150.0050.04416.28
5.6.140.0080.02016.36
5.6.130.0030.02816.26
5.6.120.0110.03117.76
5.6.110.0060.03617.52
5.6.100.0140.03617.67
5.6.90.0100.04517.77
5.6.80.0070.02517.38
5.6.70.1400.02517.22
5.6.60.0030.01214.23
5.6.50.0000.01114.47
5.6.40.0100.00614.66
5.6.30.0070.01114.41
5.6.20.0040.00814.31
5.6.10.0090.00614.26
5.6.00.0040.01514.22
5.5.380.0100.00414.09
5.5.370.0060.00614.27
5.5.360.0090.00614.30
5.5.350.0160.04417.38
5.5.340.0070.04415.96
5.5.330.0100.03217.28
5.5.320.0200.03017.24
5.5.310.0210.03417.19
5.5.300.0100.02316.24
5.5.290.0070.02516.21
5.5.280.0060.03017.52
5.5.270.0100.04717.47
5.5.260.0130.04017.44
5.5.250.0100.04517.42
5.5.240.0230.03617.14
5.5.230.0090.00614.09
5.5.220.0070.00714.02
5.5.210.0030.01314.04
5.5.200.0110.00714.20
5.5.190.0070.00414.26
5.5.180.0090.00613.68
5.5.170.0070.01014.06
5.5.160.0040.00714.25
5.5.150.0090.00014.39
5.5.140.0030.01314.00
5.5.130.0070.00714.23
5.5.120.0000.01114.20
5.5.110.0060.00914.01
5.5.100.0070.01013.95
5.5.90.0030.01414.18
5.5.80.0040.01213.80
5.5.70.0070.01014.08
5.5.60.0100.00613.90
5.5.50.0060.01014.02
5.5.40.0000.01613.70
5.5.30.0100.00714.07
5.5.20.0090.00614.16
5.5.10.0040.01114.06
5.5.00.0070.00714.12
5.4.450.0380.03016.10
5.4.440.0370.02816.01
5.4.430.0330.03316.11
5.4.420.0400.02716.03
5.4.410.0370.03316.05
5.4.400.0080.02816.01
5.4.390.0300.03715.85
5.4.380.0200.03215.72
5.4.370.0280.02315.72
5.4.360.0220.02915.69
5.4.350.0140.03015.61
5.4.340.0150.03315.74
5.4.330.0040.01112.75
5.4.320.0040.02112.61
5.4.310.0050.02012.60
5.4.300.0070.01912.61
5.4.290.0120.04312.60
5.4.280.0050.03512.55
5.4.270.0050.03812.55
5.4.260.0020.04312.55
5.4.250.0110.04412.54
5.4.240.0120.04512.55
5.4.230.0130.04312.54
5.4.220.0040.03412.54
5.4.210.0080.02412.54
5.4.200.0070.02512.54
5.4.190.0100.04712.54
5.4.180.0090.03012.54
5.4.170.0120.04412.54
5.4.160.0070.04012.54
5.4.150.0100.02812.54
5.4.140.0060.03012.38
5.4.130.0080.04212.38
5.4.120.0100.04112.36
5.4.110.0070.03612.36
5.4.100.0040.03312.35
5.4.90.0070.03312.35
5.4.80.0080.03312.36
5.4.70.0130.04312.35
5.4.60.0120.04012.35
5.4.50.0080.02812.35
5.4.40.0070.04712.35
5.4.30.0120.04412.35
5.4.20.0100.05312.34
5.4.10.0070.04212.35
5.4.00.0130.06212.09
5.3.290.0060.02512.78
5.3.280.0050.02812.73
5.3.270.0060.03112.73
5.3.260.0060.03012.73
5.3.250.0070.02812.73
5.3.240.0050.03112.73
5.3.230.0100.04012.73
5.3.220.0070.02412.71
5.3.210.0050.02412.71
5.3.200.0070.02112.71
5.3.190.0020.02712.71
5.3.180.0080.02412.71
5.3.170.0070.02312.71
5.3.160.0080.02512.71
5.3.150.0070.03412.71
5.3.140.0070.02612.71
5.3.130.0100.02912.71
5.3.120.0090.04312.70
5.3.110.0100.03612.70
5.3.100.0100.03212.43
5.3.90.0060.03612.42
5.3.80.0080.02312.41
5.3.70.0070.02012.41
5.3.60.0040.02312.41
5.3.50.0020.02612.38
5.3.40.0020.02312.37
5.3.30.0050.02412.35
5.3.20.0020.03112.25
5.3.10.0080.02412.23
5.3.00.0140.04412.22
5.2.170.0120.0709.20
5.2.160.0120.0549.20
5.2.150.0090.0659.19
5.2.140.0060.0439.20
5.2.130.0070.0329.15
5.2.120.0050.0439.15
5.2.110.0100.0389.16
5.2.100.0080.0439.15
5.2.90.0080.0389.15
5.2.80.0040.0359.15
5.2.70.0050.0349.14
5.2.60.0060.0339.10
5.2.50.0100.0309.07
5.2.40.0080.0309.05
5.2.30.0050.0349.03
5.2.20.0050.0329.02
5.2.10.0100.0528.92
5.2.00.0050.0368.78
5.1.60.0070.0248.07
5.1.50.0040.0308.06
5.1.40.0170.0828.04
5.1.30.0090.0358.39
5.1.20.0040.0298.41
5.1.10.0080.0258.14
5.1.00.0060.0268.15
5.0.50.0060.0216.61
5.0.40.0060.0296.48
5.0.30.0050.0346.30
5.0.20.0040.0276.26
5.0.10.0040.0256.24
5.0.00.0080.0556.23
4.4.90.0060.0174.78
4.4.80.0010.0194.76
4.4.70.0050.0154.76
4.4.60.0040.0204.75
4.4.50.0050.0204.77
4.4.40.0040.0414.70
4.4.30.0060.0234.76
4.4.20.0060.0334.84
4.4.10.0060.0304.85
4.4.00.0050.0374.76
4.3.110.0070.0234.67
4.3.100.0040.0414.66
4.3.90.0050.0244.64
4.3.80.0120.0624.59
4.3.70.0040.0364.63
4.3.60.0050.0194.63
4.3.50.0060.0144.63
4.3.40.0050.0314.54
4.3.30.0040.0203.29
4.3.20.0010.0233.26
4.3.10.0030.0183.22
4.3.00.0000.03310.54

preferences:
39.63 ms | 401 KiB | 5 Q