3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input= "<p>text text text</p> <p>text text text</p> <p>text text text</p> <p>text text text</p> <p>text text text</p> <p>text text text</p>"; $arr =explode(PHP_EOL, $input); $adsbeforeparagraph = array(0,2,4); // subtracted 1 to suit normal array numbering $ad = 'ADS CODE'; Foreach($arr as $key => $line){ If(in_array($key, $adsbeforeparagraph)){ // is this a line that should have Ads? Echo $ad . $line . "\n"; }else{ Echo $line . "\n"; } }

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.4.120.0110.00618.90
8.4.110.0060.00618.96
8.4.100.0130.00717.46
8.4.90.0100.00920.39
8.4.80.0150.00518.76
8.4.70.0100.00918.75
8.4.60.0090.00520.61
8.4.50.0120.00918.50
8.4.40.0120.00819.55
8.4.30.0160.00317.58
8.4.20.0070.01319.50
8.4.10.0050.00519.28
8.3.250.0130.00616.46
8.3.240.0110.00816.63
8.3.230.0140.00616.67
8.3.220.0120.00720.79
8.3.210.0110.00818.43
8.3.200.0130.00616.63
8.3.190.0090.01016.45
8.3.180.0050.00418.50
8.3.170.0090.00920.59
8.3.160.0040.00418.23
8.3.150.0060.01316.60
8.3.140.0070.00717.21
8.3.130.0150.00018.27
8.3.120.0060.00320.65
8.3.110.0030.00616.54
8.3.100.0070.00020.36
8.3.90.0110.00820.04
8.3.80.0040.00718.56
8.3.70.0000.01416.50
8.3.60.0040.01416.50
8.3.50.0070.01217.40
8.3.40.0090.00618.85
8.3.30.0030.01218.59
8.3.20.0080.00020.16
8.3.10.0040.00423.70
8.3.00.0040.00423.56
8.2.290.0090.00916.93
8.2.280.0070.00518.15
8.2.270.0100.01018.94
8.2.260.0150.00316.39
8.2.250.0040.00418.40
8.2.240.0040.00418.70
8.2.230.0060.00620.94
8.2.220.0090.00024.06
8.2.210.0070.01026.77
8.2.200.0060.00318.28
8.2.190.0090.00616.58
8.2.180.0060.00917.92
8.2.170.0150.00018.77
8.2.160.0090.00622.96
8.2.150.0000.00825.66
8.2.140.0040.00424.66
8.2.130.0000.00720.52
8.2.120.0000.00726.35
8.2.110.0060.00321.00
8.2.100.0110.00017.70
8.2.90.0040.00419.05
8.2.80.0040.00417.97
8.2.70.0000.00817.34
8.2.60.0040.00417.93
8.2.50.0000.00818.10
8.2.40.0030.00520.59
8.2.30.0060.00319.30
8.2.20.0050.00218.19
8.2.10.0050.00218.04
8.2.00.0000.00718.14
8.1.330.0090.01016.10
8.1.320.0100.01016.60
8.1.310.0040.00418.41
8.1.300.0060.00319.66
8.1.290.0060.00618.88
8.1.280.0070.01425.92
8.1.270.0040.00422.14
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0030.00721.29
8.1.230.0100.00020.30
8.1.220.0030.00517.91
8.1.210.0050.00318.77
8.1.200.0060.00317.35
8.1.190.0000.00817.12
8.1.180.0000.00718.10
8.1.170.0040.00418.59
8.1.160.0040.00418.76
8.1.150.0050.00320.18
8.1.140.0070.00019.09
8.1.130.0050.00318.80
8.1.120.0040.00417.53
8.1.110.0090.00017.51
8.1.100.0050.00217.47
8.1.90.0040.00417.38
8.1.80.0000.01117.42
8.1.70.0040.00417.45
8.1.60.0060.00317.63
8.1.50.0000.00817.36
8.1.40.0040.00417.41
8.1.30.0040.00417.62
8.1.20.0000.00917.55
8.1.10.0000.00817.51
8.1.00.0040.00417.45
8.0.300.0040.00418.77
8.0.290.0050.00316.75
8.0.280.0030.00318.50
8.0.270.0070.00017.16
8.0.260.0060.00318.84
8.0.250.0000.00716.95
8.0.240.0000.00816.93
8.0.230.0070.00016.84
8.0.220.0060.00316.89
8.0.210.0040.00416.77
8.0.200.0070.00016.97
8.0.190.0040.00416.84
8.0.180.0000.00716.88
8.0.170.0000.00716.81
8.0.160.0090.00016.90
8.0.150.0070.00016.91
8.0.140.0040.00416.84
8.0.130.0050.00013.40
8.0.120.0070.00016.91
8.0.110.0040.00416.86
8.0.100.0070.00016.95
8.0.90.0030.00316.77
8.0.80.0070.01316.86
8.0.70.0040.00416.95
8.0.60.0050.00216.70
8.0.50.0040.00416.97
8.0.30.0090.00917.13
8.0.20.0090.01217.40
8.0.10.0070.00016.84
8.0.00.0070.01016.97
7.4.330.0020.00215.55
7.4.320.0000.00716.51
7.4.300.0030.00316.65
7.4.290.0070.00016.50
7.4.280.0000.00716.44
7.4.270.0000.00716.51
7.4.260.0030.00316.59
7.4.250.0040.00416.52
7.4.240.0030.00316.57
7.4.230.0050.00316.32
7.4.220.0100.00716.68
7.4.210.0040.01116.68
7.4.200.0030.00316.67
7.4.160.0110.00916.57
7.4.150.0090.00917.40
7.4.140.0120.00617.86
7.4.130.0090.01216.63
7.4.120.0110.01016.54
7.4.110.0060.01016.58
7.4.100.0170.00616.30
7.4.90.0130.00516.50
7.4.80.0060.00919.39
7.4.70.0060.01616.40
7.4.60.0130.00316.38
7.4.50.0050.00516.41
7.4.40.0140.00316.39
7.4.30.0030.01316.40
7.4.00.0060.01015.04
7.3.330.0000.00513.02
7.3.320.0000.00613.18
7.3.310.0030.00316.32
7.3.300.0030.00316.17
7.3.290.0110.00716.26
7.3.280.0090.00616.29
7.3.270.0070.01017.40
7.3.260.0140.00516.57
7.3.250.0060.01116.49
7.3.240.0110.00816.42
7.3.230.0100.00616.64
7.3.210.0130.00316.52
7.3.200.0120.00416.27
7.3.190.0030.01316.43
7.3.180.0110.00716.34
7.3.170.0110.00516.49
7.3.160.0100.00616.33
7.2.330.0140.00716.82
7.2.320.0130.00616.80
7.2.310.0090.01516.71
7.2.300.0180.00016.64
7.2.290.0030.01316.68
7.2.60.0030.00917.05
7.1.200.0000.01315.88
7.1.110.0650.00615.97
7.1.100.0780.01016.01
7.1.90.0810.01616.32
7.1.80.0740.01215.83
7.1.70.0560.01015.24
7.1.60.0650.00733.12
7.1.50.0770.01033.03
7.1.40.0980.01032.57
7.1.30.0870.00932.63
7.1.20.1060.00932.74
7.1.10.0530.00914.75
7.1.00.0620.00614.68
7.0.250.0740.00615.54
7.0.240.0570.00715.48
7.0.230.0780.00015.75
7.0.220.0680.01515.86
7.0.210.0600.01314.94
7.0.200.0730.01014.79
7.0.190.0850.00714.99
7.0.180.0520.01014.43
7.0.170.1320.01314.59
7.0.160.0740.00414.38
7.0.150.0530.00714.45
7.0.140.0600.00714.56
7.0.130.0570.00414.70
7.0.120.0740.01014.56
7.0.110.0620.00414.44
7.0.100.0590.00014.22
7.0.90.0440.01314.48
7.0.80.0540.01014.63
7.0.70.0480.01314.50
7.0.60.0500.01214.34
7.0.50.0520.01014.57
7.0.40.0530.01214.64
7.0.30.0680.00614.57
7.0.20.0520.00714.50
7.0.10.0610.00614.51
7.0.00.0630.01014.38

preferences:
27.94 ms | 403 KiB | 5 Q