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_NO_EMPTY/PREG_SPLIT_OFFSET_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.0120.00316.75
8.3.50.0110.00921.27
8.3.40.0100.00718.61
8.3.30.0060.01219.09
8.3.20.0000.00920.35
8.3.10.0080.00023.58
8.3.00.0040.00419.51
8.2.180.0180.00018.41
8.2.170.0140.00722.96
8.2.160.0030.01720.39
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0030.00522.14
8.2.110.0120.00922.39
8.2.100.0080.00418.03
8.2.90.0080.00019.22
8.2.80.0040.00417.97
8.2.70.0080.00017.75
8.2.60.0030.00519.53
8.2.50.0080.00018.07
8.2.40.0080.00019.63
8.2.30.0000.00819.72
8.2.20.0000.00817.66
8.2.10.0040.00417.96
8.2.00.0070.00417.78
8.1.280.0100.01025.92
8.1.270.0060.00323.84
8.1.260.0080.00026.35
8.1.250.0030.00728.09
8.1.240.0090.00023.83
8.1.230.0110.00019.01
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0060.00617.35
8.1.190.0030.00617.28
8.1.180.0030.00618.10
8.1.170.0060.00318.71
8.1.160.0000.01122.02
8.1.150.0040.00418.79
8.1.140.0040.00417.57
8.1.130.0000.00717.64
8.1.120.0040.00417.55
8.1.110.0000.00817.50
8.1.100.0030.00417.56
8.1.90.0000.00717.56
8.1.80.0000.00817.57
8.1.70.0050.00317.45
8.1.60.0000.00817.57
8.1.50.0030.00517.61
8.1.40.0030.00617.54
8.1.30.0030.00617.74
8.1.20.0000.00717.67
8.1.10.0090.00017.60
8.1.00.0020.00517.41
8.0.300.0040.00420.70
8.0.290.0040.00417.18
8.0.280.0000.00818.33
8.0.270.0030.00317.18
8.0.260.0030.00316.87
8.0.250.0000.00717.00
8.0.240.0070.00017.09
8.0.230.0030.00717.04
8.0.220.0030.00316.89
8.0.210.0060.00316.98
8.0.200.0030.00316.95
8.0.190.0040.00417.05
8.0.180.0070.00016.96
8.0.170.0070.00017.01
8.0.160.0030.00516.91
8.0.150.0000.00716.99
8.0.140.0040.00416.96
8.0.130.0000.00713.40
8.0.120.0000.00816.97
8.0.110.0040.00416.89
8.0.100.0050.00216.95
8.0.90.0000.00716.79
8.0.80.0060.00916.88
8.0.70.0040.00416.89
8.0.60.0040.00416.87
8.0.50.0040.00317.00
8.0.30.0130.00617.06
8.0.20.0090.00917.40
8.0.10.0000.00717.04
8.0.00.0100.00816.91
7.4.330.0020.00215.00
7.4.320.0000.00716.76
7.4.300.0040.00416.65
7.4.290.0030.00616.64
7.4.280.0060.00316.65
7.4.270.0040.00316.58
7.4.260.0070.00016.74
7.4.250.0050.00316.48
7.4.240.0020.00516.72
7.4.230.0030.00316.65
7.4.220.0060.01916.76
7.4.210.0060.00816.69
7.4.200.0020.00516.78
7.4.190.0030.00316.72
7.4.160.0090.00616.36
7.4.150.0070.01117.40
7.4.140.0110.00517.86
7.4.130.0130.00516.60
7.4.120.0070.01116.49
7.4.110.0070.01516.74
7.4.100.0120.00916.50
7.4.90.0120.00616.53
7.4.80.0030.01319.39
7.4.70.0060.01216.62
7.4.60.0060.00916.70
7.4.50.0000.00916.50
7.4.40.0040.01422.77
7.4.30.0090.00916.46
7.4.10.0030.01515.25
7.4.00.0090.00715.02
7.3.330.0020.00213.02
7.3.320.0000.00613.22
7.3.310.0000.00716.38
7.3.300.0000.00716.28
7.3.290.0090.00916.27
7.3.280.0050.01216.28
7.3.270.0110.00617.40
7.3.260.0060.01016.60
7.3.250.0080.01216.63
7.3.240.0080.01216.25
7.3.230.0130.00316.41
7.3.210.0120.00616.52
7.3.200.0070.01519.39
7.3.190.0100.00616.63
7.3.180.0090.00816.24
7.3.170.0040.01216.52
7.3.160.0070.01016.48
7.3.130.0060.01314.54
7.3.120.0060.00914.74
7.3.110.0080.00614.86
7.3.100.0050.00914.88
7.3.90.0030.01114.95
7.3.80.0040.01014.85
7.3.70.0050.00714.78
7.3.60.0050.00714.65
7.3.50.0060.00614.85
7.3.40.0050.00614.79
7.3.30.0040.01014.81
7.3.20.0040.01016.59
7.3.10.0040.00816.59
7.3.00.0040.01016.55
7.2.330.0100.00716.73
7.2.320.0120.01016.75
7.2.310.0030.01316.63
7.2.300.0130.00416.45
7.2.290.0070.01016.70
7.2.260.0110.00715.08
7.2.250.0090.00915.03
7.2.240.0060.01015.00
7.2.230.0060.01014.85
7.2.220.0070.00915.07
7.2.210.0090.00515.06
7.2.200.0020.01114.94
7.2.190.0030.01115.06
7.2.180.0060.00815.09
7.2.170.0060.00915.03
7.2.160.0030.00814.97
7.2.150.0060.00816.89
7.2.140.0060.01016.72
7.2.130.0080.00616.97
7.2.120.0030.01016.88
7.2.110.0080.00516.74
7.2.100.0060.00816.87
7.2.90.0490.00616.92
7.2.80.0070.01016.82
7.2.70.0060.00916.98
7.2.60.0060.01116.98
7.2.50.0090.00516.88
7.2.40.0050.00816.83
7.2.30.0200.00717.01
7.2.20.0060.00716.95
7.2.10.0090.00717.02
7.2.00.0060.00617.27
7.1.330.0080.00615.87
7.1.320.0050.00815.88
7.1.310.0060.00715.88
7.1.300.0070.00615.76
7.1.290.0060.00816.01
7.1.280.0070.00915.81
7.1.270.0080.00615.85
7.1.260.0050.00715.97
7.1.250.0060.00515.75
7.1.240.0040.00715.97
7.1.230.0100.00215.99
7.1.220.0090.00515.79
7.1.210.0100.00715.74
7.1.200.0090.00515.81
7.1.190.0060.00715.72
7.1.180.0050.00815.74
7.1.170.0270.00815.67
7.1.160.0060.00915.82
7.1.150.0060.00815.73
7.1.140.0080.00815.90
7.1.130.0070.01015.69
7.1.120.0110.00515.72
7.1.110.0190.01015.89
7.1.100.0070.00916.71
7.1.90.0070.00815.83
7.1.80.0120.00216.02
7.1.70.0050.00816.38
7.1.60.0090.00917.18
7.1.50.0090.01016.35
7.1.40.0060.00715.93
7.1.30.0100.00616.02
7.1.20.0040.01215.89
7.1.10.0040.01015.78
7.1.00.0100.02818.01
7.0.330.0030.01015.50
7.0.320.0090.00015.48
7.0.310.0400.00515.27
7.0.300.0100.00615.56
7.0.290.0100.00315.46
7.0.280.0110.00115.35
7.0.270.0110.00815.48
7.0.260.0090.00615.61
7.0.250.0060.01015.45
7.0.240.0210.00715.44
7.0.230.0060.00615.53
7.0.220.0060.00715.69
7.0.210.0060.01015.23
7.0.200.0080.00716.03
7.0.190.0070.00515.34
7.0.180.0090.00615.55
7.0.170.0090.00915.48
7.0.160.0090.00415.38
7.0.150.0090.00715.32
7.0.140.0100.02617.57
7.0.130.0070.00815.57
7.0.120.0070.00815.62
7.0.110.0070.00815.65
7.0.100.0090.00615.45
7.0.90.0080.00815.47
7.0.80.0110.00415.54
7.0.70.0110.00615.58
7.0.60.0050.02116.88
7.0.50.0090.03316.28
7.0.40.0140.02715.81
7.0.30.0180.01715.81
7.0.20.0100.02015.77
7.0.10.0100.02215.78
7.0.00.0090.03415.91
5.6.400.0120.00314.54
5.6.390.0150.00014.11
5.6.380.0040.00814.11
5.6.370.0120.00314.29
5.6.360.0120.00314.53
5.6.350.0070.00814.32
5.6.340.0130.00414.28
5.6.330.0060.00614.07
5.6.320.0060.00914.33
5.6.310.0120.00414.19
5.6.300.0050.00914.51
5.6.290.0160.00014.32
5.6.280.0100.02716.45
5.6.270.0080.00614.33
5.6.260.0100.00714.31
5.6.250.0120.00314.30
5.6.240.0060.01014.16
5.6.230.0060.00814.17
5.6.220.0060.01014.43
5.6.210.0090.03316.41
5.6.200.0110.03015.57
5.6.190.0060.02616.39
5.6.180.0090.02516.26
5.6.170.0130.02416.56
5.6.160.0040.02116.36
5.6.150.0060.03615.51
5.6.140.0060.02315.52
5.6.130.0090.01515.50
5.6.120.0050.02216.54
5.6.110.0040.03416.41
5.6.100.0020.03316.61
5.6.90.0090.01616.50
5.6.80.0110.02816.20
5.6.70.1510.01616.33
5.6.60.0060.00914.35
5.6.50.0090.00714.16
5.6.40.0060.00814.22
5.6.30.0090.00914.30
5.6.20.0090.00614.38
5.6.10.0070.00714.19
5.6.00.0110.00614.26
5.5.380.0040.00913.39
5.5.370.0110.00313.48
5.5.360.0070.00813.43
5.5.350.0130.03315.60
5.5.340.0100.02914.97
5.5.330.0090.02115.78
5.5.320.0120.02215.77
5.5.310.0140.03215.92
5.5.300.0090.02314.90
5.5.290.0050.03214.89
5.5.280.0040.01915.87
5.5.270.0030.03415.97
5.5.260.0100.03215.93
5.5.250.0110.02615.83
5.5.240.0160.02715.64
5.5.230.0010.01213.46
5.5.220.0050.00913.38
5.5.210.0030.01013.35
5.5.200.0080.00313.54
5.5.190.0090.00413.22
5.5.180.0060.00613.36
5.5.170.0080.00614.15
5.5.160.0110.00513.50
5.5.150.0060.00613.51
5.5.140.0110.00313.46
5.5.130.0080.00713.52
5.5.120.0100.00213.40
5.5.110.0080.00513.57
5.5.100.0100.00413.32
5.5.90.0100.00113.48
5.5.80.0080.00713.47
5.5.70.0100.00613.43
5.5.60.0070.00613.47
5.5.50.0050.00713.36
5.5.40.0080.00513.50
5.5.30.0020.01013.49
5.5.20.0040.00913.54
5.5.10.0030.00913.48
5.5.00.0070.00813.29
5.4.450.0230.02614.95
5.4.440.0210.02514.90
5.4.430.0050.02615.02
5.4.420.0260.02314.99
5.4.410.0230.02514.92
5.4.400.0290.02014.83
5.4.390.0290.02014.88
5.4.380.0160.02114.68
5.4.370.0170.01914.74
5.4.360.0140.02214.73
5.4.350.0100.02514.78
5.4.340.0130.02114.70
5.4.330.0110.00312.75
5.4.320.0070.01412.66
5.4.310.0050.01712.66
5.4.300.0070.01712.66
5.4.290.0080.02112.65
5.4.280.0110.02112.62
5.4.270.0110.02112.62
5.4.260.0050.02212.62
5.4.250.0050.01912.62
5.4.240.0080.02612.62
5.4.230.0090.01812.62
5.4.220.0060.01912.62
5.4.210.0050.02012.62
5.4.200.0130.02912.62
5.4.190.0090.03212.62
5.4.180.0070.02512.62
5.4.170.0070.02512.62
5.4.160.0090.02112.62
5.4.150.0120.04512.62
5.4.140.0060.02712.51
5.4.130.0090.01712.51
5.4.120.0150.03912.50
5.4.110.0060.02112.49
5.4.100.0060.02412.49
5.4.90.0090.02612.49
5.4.80.0080.02512.49
5.4.70.0100.03112.49
5.4.60.0070.01512.49
5.4.50.0040.01712.49
5.4.40.0050.01812.49
5.4.30.0100.01412.49
5.4.20.0070.01612.49
5.4.10.0090.02212.49
5.4.00.0070.02212.32
5.3.290.0070.01712.77
5.3.280.0070.01912.73
5.3.270.0080.01812.74
5.3.260.0100.02512.74
5.3.250.0080.01612.74
5.3.240.0090.01712.74
5.3.230.0070.01812.74
5.3.220.0090.02712.73
5.3.210.0120.02912.72
5.3.200.0100.02412.72
5.3.190.0090.01712.72
5.3.180.0090.02112.72
5.3.170.0110.02212.72
5.3.160.0100.01812.72
5.3.150.0070.02712.72
5.3.140.0100.02812.72
5.3.130.0100.02212.72
5.3.120.0130.02912.72
5.3.110.0080.02412.72
5.3.100.0080.02112.54
5.3.90.0040.02612.53
5.3.80.0060.02112.53
5.3.70.0070.02412.53
5.3.60.0100.02412.52
5.3.50.0080.02112.51
5.3.40.0090.02112.51
5.3.30.0090.02312.49
5.3.20.0120.02312.42
5.3.10.0080.02212.41
5.3.00.0080.02412.40
5.2.170.0070.02311.00
5.2.160.0050.02411.00
5.2.150.0080.02511.00
5.2.140.0050.02011.00
5.2.130.0050.01910.98
5.2.120.0050.01910.98
5.2.110.0070.01710.98
5.2.100.0080.01810.98
5.2.90.0090.01510.98
5.2.80.0070.01810.98
5.2.70.0060.01910.98
5.2.60.0050.01910.96
5.2.50.0080.01610.94
5.2.40.0080.01410.93
5.2.30.0070.01610.92
5.2.20.0070.01610.92
5.2.10.0050.02410.86
5.2.00.0110.02110.79
5.1.60.0070.02110.43
5.1.50.0050.02010.43
5.1.40.0100.03510.42
5.1.30.0090.03610.59
5.1.20.0080.02010.60
5.1.10.0040.02110.46
5.1.00.0060.01910.46
5.0.50.0060.0249.70
5.0.40.0030.0299.63
5.0.30.0070.0269.54
5.0.20.0060.0179.52
5.0.10.0030.0169.51
5.0.00.0050.0229.51
4.4.90.0040.0128.79
4.4.80.0040.0128.77
4.4.70.0020.0138.77
4.4.60.0040.0118.77
4.4.50.0050.0148.78
4.4.40.0030.0208.75
4.4.30.0020.0158.77
4.4.20.0050.0118.82
4.4.10.0030.0138.82
4.4.00.0060.0158.77
4.3.110.0020.0148.73
4.3.100.0020.0178.73
4.3.90.0050.0138.71
4.3.80.0060.0208.69
4.3.70.0030.0118.71
4.3.60.0040.0098.71
4.3.50.0020.0138.71
4.3.40.0020.0208.66
4.3.30.0010.0148.04
4.3.20.0030.0118.03
4.3.10.0020.0118.00
4.3.00.0020.01211.66

preferences:
42.41 ms | 401 KiB | 5 Q