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_SPLIT_DELIM_CAPTURE); print_r($arr); //$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.0140.00716.75
8.3.50.0110.00521.21
8.3.40.0130.00618.67
8.3.30.0110.00718.92
8.3.20.0040.00420.17
8.3.10.0060.00323.66
8.3.00.0060.00319.25
8.2.180.0190.00018.54
8.2.170.0100.01022.96
8.2.160.0100.00320.35
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0110.00326.16
8.2.120.0080.00022.11
8.2.110.0080.00322.25
8.2.100.0110.00017.78
8.2.90.0050.00319.27
8.2.80.0000.00817.97
8.2.70.0060.00317.75
8.2.60.0050.00319.53
8.2.50.0080.00018.07
8.2.40.0040.00419.66
8.2.30.0050.00219.81
8.2.20.0000.00717.66
8.2.10.0000.00717.94
8.2.00.0070.00417.85
8.1.280.0090.01225.92
8.1.270.0040.00423.96
8.1.260.0050.00326.35
8.1.250.0030.00628.09
8.1.240.0000.00823.97
8.1.230.0080.00319.04
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0040.00417.51
8.1.180.0030.00618.10
8.1.170.0050.00318.70
8.1.160.0030.00621.98
8.1.150.0040.00418.77
8.1.140.0000.00717.61
8.1.130.0000.00717.88
8.1.120.0000.00717.57
8.1.110.0040.00417.43
8.1.100.0040.00417.55
8.1.90.0050.00217.54
8.1.80.0040.00417.54
8.1.70.0040.00417.57
8.1.60.0000.00917.56
8.1.50.0080.00017.59
8.1.40.0040.00417.58
8.1.30.0050.00317.70
8.1.20.0040.00417.75
8.1.10.0060.00317.52
8.1.00.0060.00317.43
8.0.300.0060.00320.70
8.0.290.0020.00516.93
8.0.280.0030.00318.46
8.0.270.0040.00417.09
8.0.260.0000.00617.09
8.0.250.0030.00316.93
8.0.240.0030.00516.97
8.0.230.0030.00617.09
8.0.220.0070.00016.96
8.0.210.0090.00016.97
8.0.200.0000.00717.04
8.0.190.0020.00516.93
8.0.180.0040.00316.96
8.0.170.0040.00417.04
8.0.160.0050.00216.97
8.0.150.0050.00317.00
8.0.140.0000.00716.84
8.0.130.0040.00413.41
8.0.120.0080.00017.00
8.0.110.0040.00416.96
8.0.100.0000.00816.88
8.0.90.0020.00517.02
8.0.80.0040.01116.86
8.0.70.0050.00216.78
8.0.60.0070.00016.76
8.0.50.0070.00017.02
8.0.30.0170.00617.30
8.0.20.0110.00817.40
8.0.10.0000.00717.08
8.0.00.0090.01216.89
7.4.330.0060.00015.00
7.4.320.0030.00316.71
7.4.300.0060.00016.75
7.4.290.0030.00616.75
7.4.280.0000.00716.64
7.4.270.0030.00316.65
7.4.260.0030.00316.73
7.4.250.0050.00316.48
7.4.240.0020.00516.73
7.4.230.0030.00316.58
7.4.220.0040.01516.79
7.4.210.0060.01016.77
7.4.200.0080.00016.78
7.4.190.0070.00016.84
7.4.160.0110.00416.57
7.4.150.0060.01217.40
7.4.140.0110.01117.86
7.4.130.0080.01216.61
7.4.120.0070.01016.61
7.4.110.0100.01016.81
7.4.100.0070.01416.76
7.4.90.0100.00716.35
7.4.80.0060.01019.39
7.4.70.0130.00316.63
7.4.60.0070.01016.50
7.4.50.0040.00016.38
7.4.40.0100.00722.77
7.4.30.0000.01616.69
7.4.10.0030.01616.00
7.4.00.0070.01015.60
7.3.330.0000.00513.05
7.3.320.0000.00613.27
7.3.310.0040.00416.12
7.3.300.0030.00316.16
7.3.290.0070.01016.33
7.3.280.0110.00716.36
7.3.270.0170.00017.40
7.3.260.0130.00316.56
7.3.250.0110.00816.40
7.3.240.0070.01516.41
7.3.230.0070.01016.39
7.3.210.0030.01816.34
7.3.200.0090.01219.39
7.3.190.0070.01416.38
7.3.180.0100.00716.39
7.3.170.0090.00616.52
7.3.160.0040.01216.24
7.3.130.0070.01316.00
7.3.120.0050.01115.53
7.3.110.0080.01015.44
7.3.100.0080.00515.39
7.3.90.0070.00815.28
7.3.80.0060.00815.39
7.3.70.0090.00615.46
7.3.60.0080.00815.45
7.3.50.0090.00715.47
7.3.40.0050.00715.44
7.3.30.0080.00615.46
7.3.20.0140.00316.71
7.3.10.0110.00516.63
7.3.00.0050.00816.62
7.2.330.0120.00616.87
7.2.320.0040.01316.67
7.2.310.0130.00316.68
7.2.300.0110.01116.60
7.2.290.0060.01216.77
7.2.260.0040.01516.00
7.2.250.0090.00616.00
7.2.240.0090.00615.50
7.2.230.0090.00515.53
7.2.220.0050.01215.59
7.2.210.0050.01015.43
7.2.200.0050.00915.44
7.2.190.0070.00915.51
7.2.180.0050.00915.50
7.2.170.0080.00615.45
7.2.160.0050.00915.63
7.2.150.0040.01216.65
7.2.140.0050.01316.80
7.2.130.0060.01016.86
7.2.120.0060.00816.88
7.2.110.0060.00917.03
7.2.100.0060.01016.91
7.2.90.0040.01116.98
7.2.80.0090.00816.84
7.2.70.0010.01217.02
7.2.60.0070.00416.77
7.2.50.0060.00817.05
7.2.40.0060.00717.13
7.2.30.0050.01016.98
7.2.20.0020.01316.84
7.2.10.0060.01016.95
7.2.00.0070.00817.72
7.1.330.0070.00815.90
7.1.320.0060.00816.06
7.1.310.0080.00315.72
7.1.300.0050.00915.98
7.1.290.0060.00515.91
7.1.280.0060.00916.02
7.1.270.0000.01315.88
7.1.260.0030.01015.99
7.1.250.0050.00815.89
7.1.240.0040.01116.00
7.1.230.0040.01116.00
7.1.220.0040.00416.00
7.1.210.0000.00816.00
7.1.200.0030.01016.02
7.1.190.0120.00016.00
7.1.180.0110.00416.04
7.1.170.0080.00816.00
7.1.160.0070.00716.00
7.1.150.0030.01216.00
7.1.140.0120.00416.00
7.1.130.0030.01316.00
7.1.120.0080.00816.00
7.1.110.0070.00716.00
7.1.100.0060.00417.22
7.1.90.0040.01116.00
7.1.80.0030.01316.00
7.1.70.0060.00916.59
7.1.60.0070.00817.73
7.1.50.0070.01016.54
7.1.40.0040.01116.00
7.1.30.0100.00716.00
7.1.20.0070.00716.00
7.1.10.0130.00316.00
7.1.00.0110.03619.15
7.0.330.0100.00716.00
7.0.320.0030.01016.00
7.0.310.0070.00716.00
7.0.300.0100.00016.00
7.0.290.0130.00016.00
7.0.280.0080.00516.00
7.0.270.0040.00416.00
7.0.260.0060.00316.00
7.0.250.0030.00616.00
7.0.240.0000.01516.00
7.0.230.0040.00716.00
7.0.220.0060.01016.00
7.0.210.0100.00716.00
7.0.200.0050.00516.47
7.0.190.0000.01016.00
7.0.180.0000.01516.00
7.0.170.0070.00716.00
7.0.160.0090.00316.00
7.0.150.0000.01516.00
7.0.140.0070.03319.03
7.0.130.0050.00516.00
7.0.120.0110.00416.00
7.0.110.0060.00616.00
7.0.100.0000.01416.00
7.0.90.0030.00916.00
7.0.80.0040.00716.00
7.0.70.0110.00016.00
7.0.60.0050.04117.99
7.0.50.0050.04216.95
7.0.40.0030.02918.09
7.0.30.0200.03018.14
7.0.20.0190.04218.12
7.0.10.0080.03018.12
7.0.00.0100.04518.05
5.6.400.0030.00916.00
5.6.390.0060.01016.00
5.6.380.0040.00716.00
5.6.370.0000.01316.00
5.6.360.0080.00816.00
5.6.350.0070.00716.00
5.6.340.0030.00916.00
5.6.330.0080.00416.00
5.6.320.0080.00816.00
5.6.310.0100.00616.00
5.6.300.0150.00316.00
5.6.290.0070.00716.00
5.6.280.0050.04018.44
5.6.270.0040.00816.00
5.6.260.0050.00816.00
5.6.250.0060.00616.00
5.6.240.0030.01016.00
5.6.230.0060.00916.00
5.6.220.0030.01016.00
5.6.210.0060.04418.25
5.6.200.0050.04517.11
5.6.190.0080.02318.28
5.6.180.0130.04218.17
5.6.170.0200.04018.28
5.6.160.0060.03318.27
5.6.150.0050.03417.11
5.6.140.0080.04117.12
5.6.130.0090.04417.07
5.6.120.0030.02518.47
5.6.110.0070.03118.48
5.6.100.0100.04018.44
5.6.90.0050.03918.51
5.6.80.0050.03918.17
5.6.70.2250.02618.20
5.6.60.0100.00316.00
5.6.50.0070.00716.00
5.6.40.0070.01016.00
5.6.30.0070.00716.00
5.6.20.0070.00716.00
5.6.10.0140.00316.00
5.6.00.0060.00616.00
5.5.380.0070.00316.00
5.5.370.0080.00616.00
5.5.360.0030.00916.00
5.5.350.0050.04218.18
5.5.340.0080.02717.03
5.5.330.0070.04318.14
5.5.320.0070.03718.15
5.5.310.0100.02518.17
5.5.300.0050.04516.98
5.5.290.0060.03216.97
5.5.280.0040.03418.38
5.5.270.0110.04518.44
5.5.260.0020.03618.42
5.5.250.0100.04018.34
5.5.240.0170.04218.13
5.5.230.0130.00316.00
5.5.220.0120.00316.00
5.5.210.0000.01316.00
5.5.200.0050.00516.00
5.5.190.0150.00016.00
5.5.180.0080.00616.00
5.5.170.0070.00316.00
5.5.160.0120.00316.00
5.5.150.0050.00516.00
5.5.140.0000.01316.00
5.5.130.0070.00716.00
5.5.120.0040.01116.00
5.5.110.0110.00316.00
5.5.100.0060.00616.00
5.5.90.0060.01216.00
5.5.80.0100.00016.00
5.5.70.0030.01016.00
5.5.60.0070.00716.00
5.5.50.0070.01016.00
5.5.40.0000.00916.00
5.5.30.0120.00016.00
5.5.20.0100.00316.00
5.5.10.0070.00716.00
5.5.00.0030.01016.00
5.4.450.0350.03217.81
5.4.440.0510.03717.78
5.4.430.0420.02717.78
5.4.420.0470.03417.65
5.4.410.0360.04317.67
5.4.400.0400.03017.62
5.4.390.0380.03317.64
5.4.380.0230.02617.23
5.4.370.0150.02717.25
5.4.360.0160.03017.39
5.4.350.0120.03317.27
5.4.340.0180.02817.38
5.4.330.0030.00916.00
5.4.320.0020.02114.24
5.4.310.0060.02014.24
5.4.300.0030.02314.24
5.4.290.0090.04614.23
5.4.280.0120.04014.18
5.4.270.0090.04414.18
5.4.260.0110.03814.18
5.4.250.0040.03114.18
5.4.240.0130.04614.18
5.4.230.0050.03714.18
5.4.220.0110.04214.18
5.4.210.0130.03814.18
5.4.200.0100.04014.18
5.4.190.0100.04314.18
5.4.180.0040.05114.18
5.4.170.0100.03614.18
5.4.160.0100.04114.18
5.4.150.0070.03914.18
5.4.140.0180.04014.02
5.4.130.0120.03814.01
5.4.120.0190.04713.99
5.4.110.0100.04713.99
5.4.100.0140.04113.99
5.4.90.0140.03613.99
5.4.80.0100.03613.99
5.4.70.0100.04113.99
5.4.60.0190.04313.99
5.4.50.0090.03713.99
5.4.40.0100.03713.98
5.4.30.0100.03013.98
5.4.20.0100.03313.98
5.4.10.0120.04113.98
5.4.00.0100.04513.73
5.3.290.0030.02214.40
5.3.280.0120.06714.35
5.3.270.0080.04314.36
5.3.260.0060.03314.36
5.3.250.0100.04514.36
5.3.240.0090.03114.36
5.3.230.0080.04114.35
5.3.220.0070.03114.34
5.3.210.0150.03214.34
5.3.200.0100.02814.34
5.3.190.0080.05314.34
5.3.180.0080.04014.34
5.3.170.0060.03114.33
5.3.160.0160.04914.33
5.3.150.0060.04214.33
5.3.140.0110.03714.33
5.3.130.0090.03214.33
5.3.120.0080.05314.32
5.3.110.0020.03314.33
5.3.100.0190.05614.06
5.3.90.0090.03114.05
5.3.80.0110.04614.04
5.3.70.0170.04814.04
5.3.60.0140.04714.04
5.3.50.0140.05414.01
5.3.40.0110.03614.01
5.3.30.0140.03613.99
5.3.20.0110.03613.88
5.3.10.0140.02913.86
5.3.00.0090.02313.86
5.2.170.0200.0659.22
5.2.160.0150.0749.21
5.2.150.0130.0469.21
5.2.140.0120.0619.21
5.2.130.0090.0429.18
5.2.120.0170.0639.18
5.2.110.0150.0579.18
5.2.100.0130.0489.18
5.2.90.0070.0519.18
5.2.80.0250.0709.17
5.2.70.0120.0739.18
5.2.60.0160.0799.13
5.2.50.0190.0699.09
5.2.40.0270.0779.07
5.2.30.0280.0649.05
5.2.20.0120.0389.04
5.2.10.0070.0418.94
5.2.00.0200.0458.80
5.1.60.0210.0898.07
5.1.50.0060.0338.06
5.1.40.0050.0348.04
5.1.30.0050.0398.39
5.1.20.0080.0378.41
5.1.10.0240.0638.14
5.1.00.0140.0478.15
5.0.50.0050.0476.62
5.0.40.0060.0286.48
5.0.30.0050.0436.29
5.0.20.0090.0236.26
5.0.10.0060.0276.24
5.0.00.0070.0396.23
4.4.90.0060.0264.78
4.4.80.0050.0254.76
4.4.70.0050.0214.75
4.4.60.0050.0204.76
4.4.50.0070.0284.77
4.4.40.0020.0374.71
4.4.30.0050.0224.76
4.4.20.0060.0224.84
4.4.10.0070.0264.85
4.4.00.0070.0334.76
4.3.110.0080.0224.67
4.3.100.0050.0234.67
4.3.90.0080.0194.64
4.3.80.0040.0374.59
4.3.70.0060.0214.63
4.3.60.0030.0244.63
4.3.50.0070.0214.63
4.3.40.0080.0324.54
4.3.30.0080.0393.29
4.3.20.0080.0403.26
4.3.10.0080.0383.22
4.3.00.0100.01313.17

preferences:
47.07 ms | 400 KiB | 5 Q