3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $n = 8000; $start = microtime(true); $arr = array(); if ($n >= 2) $arr[] = 2; for ($i = 3; $i<=$n; $i+=2) { $arr[] = $i; } foreach ($arr as $key=>$row) { foreach($arr as $key2=>$row2) { if ($key2 > $key && ($row2 % $row) === 0) { unset($arr[$key2]); } } } $arr = array_values($arr); echo '<pre>'; echo array_sum($arr), PHP_EOL; echo (microtime(true)-$start);
Output for 7.1.0
<pre>3738566 0.17984104156494
Output for 7.0.14
<pre>3738566 0.22935485839844
Output for 7.0.12
<pre>3738566 0.14900398254395
Output for 7.0.9
<pre>3738566 0.13723015785217
Output for 7.0.8
<pre>3738566 0.1773087978363
Output for 7.0.7
<pre>3738566 0.1589150428772
Output for 7.0.6
<pre>3738566 0.15890407562256
Output for 7.0.5
<pre>3738566 0.17474913597107
Output for 7.0.4
<pre>3738566 0.18390583992004
Output for 7.0.3
<pre>3738566 0.17934703826904
Output for 7.0.2
<pre>3738566 0.18832588195801
Output for 7.0.1
<pre>3738566 0.17770504951477
Output for 7.0.0
<pre>3738566 0.16955518722534
Output for 5.6.28
<pre>3738566 0.049010038375854
Output for 5.6.23
<pre>3738566 0.23086404800415
Output for 5.6.22
<pre>3738566 0.2354531288147
Output for 5.6.21
<pre>3738566 0.26107001304626
Output for 5.6.20
<pre>3738566 0.30385303497314
Output for 5.6.19
<pre>3738566 0.24492597579956
Output for 5.6.18
<pre>3738566 0.25080704689026
Output for 5.6.17
<pre>3738566 0.26554298400879
Output for 5.6.16
<pre>3738566 0.24569296836853
Output for 5.6.15
<pre>3738566 0.27619814872742
Output for 5.6.14
<pre>3738566 0.26085901260376
Output for 5.6.13
<pre>3738566 0.26361989974976
Output for 5.6.12
<pre>3738566 0.2525360584259
Output for 5.6.11
<pre>3738566 0.28176498413086
Output for 5.6.10
<pre>3738566 0.24618697166443
Output for 5.6.9
<pre>3738566 0.28198504447937
Output for 5.6.8
<pre>3738566 0.24411606788635
Output for 5.6.7
<pre>3738566 0.24231600761414
Output for 5.6.6
<pre>3738566 0.28288912773132
Output for 5.6.5
<pre>3738566 0.29312086105347
Output for 5.6.4
<pre>3738566 0.22038888931274
Output for 5.6.3
<pre>3738566 0.25681805610657
Output for 5.6.2
<pre>3738566 0.26796889305115
Output for 5.6.1
<pre>3738566 0.25546216964722
Output for 5.6.0
<pre>3738566 0.25394010543823
Output for 5.5.37
<pre>3738566 0.20948815345764
Output for 5.5.36
<pre>3738566 0.20844101905823
Output for 5.5.35
<pre>3738566 0.26869797706604
Output for 5.5.34
<pre>3738566 0.27007579803467
Output for 5.5.33
<pre>3738566 0.24727892875671
Output for 5.5.32
<pre>3738566 0.26119899749756
Output for 5.5.31
<pre>3738566 0.27514100074768
Output for 5.5.30
<pre>3738566 0.25728297233582
Output for 5.5.29
<pre>3738566 0.27295899391174
Output for 5.5.28
<pre>3738566 0.28011703491211
Output for 5.5.27
<pre>3738566 0.26103186607361
Output for 5.5.26
<pre>3738566 0.28267598152161
Output for 5.5.25
<pre>3738566 0.27907395362854
Output for 5.5.24
<pre>3738566 0.26758408546448
Output for 5.5.23
<pre>3738566 0.24961709976196
Output for 5.5.22
<pre>3738566 0.27891397476196
Output for 5.5.21
<pre>3738566 0.27958798408508
Output for 5.5.20
<pre>3738566 0.27989411354065
Output for 5.5.19
<pre>3738566 0.28708100318909
Output for 5.5.18
<pre>3738566 0.30479907989502
Output for 5.5.16
<pre>3738566 0.31054520606995
Output for 5.5.15
<pre>3738566 0.27924680709839
Output for 5.5.14
<pre>3738566 0.28670907020569
Output for 5.5.13
<pre>3738566 0.28290200233459
Output for 5.5.12
<pre>3738566 0.27081799507141
Output for 5.5.11
<pre>3738566 0.27893400192261
Output for 5.5.10
<pre>3738566 0.26730585098267
Output for 5.5.9
<pre>3738566 0.25312185287476
Output for 5.5.8
<pre>3738566 0.26052808761597
Output for 5.5.7
<pre>3738566 0.29796290397644
Output for 5.5.6
<pre>3738566 0.24939298629761
Output for 5.5.5
<pre>3738566 0.27274012565613
Output for 5.5.4
<pre>3738566 0.27690720558167
Output for 5.5.3
<pre>3738566 0.29260206222534
Output for 5.5.2
<pre>3738566 0.28030896186829
Output for 5.5.1
<pre>3738566 0.25730895996094
Output for 5.5.0
<pre>3738566 0.26964592933655
Output for 5.4.45
<pre>3738566 0.26386308670044
Output for 5.4.44
<pre>3738566 0.28743982315063
Output for 5.4.43
<pre>3738566 0.26981401443481
Output for 5.4.42
<pre>3738566 0.28926181793213
Output for 5.4.41
<pre>3738566 0.27349185943604
Output for 5.4.40
<pre>3738566 0.26009511947632
Output for 5.4.39
<pre>3738566 0.27574181556702
Output for 5.4.38
<pre>3738566 0.25987195968628
Output for 5.4.37
<pre>3738566 0.25558614730835
Output for 5.4.36
<pre>3738566 0.2778639793396
Output for 5.4.35
<pre>3738566 0.29965710639954
Output for 5.4.34
<pre>3738566 0.29614090919495
Output for 5.4.32
<pre>3738566 0.27814388275146
Output for 5.4.31
<pre>3738566 0.25741696357727
Output for 5.4.30
<pre>3738566 0.29229497909546
Output for 5.4.29
<pre>3738566 0.26713490486145
Output for 5.4.28
<pre>3738566 0.2821249961853
Output for 5.4.27
<pre>3738566 0.2633261680603
Output for 5.4.26
<pre>3738566 0.26665878295898
Output for 5.4.25
<pre>3738566 0.26997900009155
Output for 5.4.24
<pre>3738566 0.27478289604187
Output for 5.4.23
<pre>3738566 0.26058292388916
Output for 5.4.22
<pre>3738566 0.27510190010071
Output for 5.4.21
<pre>3738566 0.26392388343811
Output for 5.4.20
<pre>3738566 0.27005791664124
Output for 5.4.19
<pre>3738566 0.29715013504028
Output for 5.4.18
<pre>3738566 0.32248997688293
Output for 5.4.17
<pre>3738566 0.23024201393127
Output for 5.4.16
<pre>3738566 0.32203197479248
Output for 5.4.15
<pre>3738566 0.31119608879089
Output for 5.4.14
<pre>3738566 0.25558018684387
Output for 5.4.13
<pre>3738566 0.25888323783875
Output for 5.4.12
<pre>3738566 0.25550079345703
Output for 5.4.11
<pre>3738566 0.3049099445343
Output for 5.4.10
<pre>3738566 0.29277801513672
Output for 5.4.9
<pre>3738566 0.29561305046082
Output for 5.4.8
<pre>3738566 0.25549912452698
Output for 5.4.7
<pre>3738566 0.27036809921265
Output for 5.4.6
<pre>3738566 0.23120784759521
Output for 5.4.5
<pre>3738566 0.25284481048584
Output for 5.4.4
<pre>3738566 0.24414801597595
Output for 5.4.3
<pre>3738566 0.26787209510803
Output for 5.4.2
<pre>3738566 0.20569491386414
Output for 5.4.1
<pre>3738566 0.24602007865906
Output for 5.4.0
<pre>3738566 0.20199108123779
Output for 5.3.29
<pre>3738566 0.33840394020081
Output for 5.3.28
<pre>3738566 0.31330418586731
Output for 5.3.27
<pre>3738566 0.29087901115417
Output for 5.3.26
<pre>3738566 0.3184130191803
Output for 5.3.25
<pre>3738566 0.36597204208374
Output for 5.3.24
<pre>3738566 0.31250596046448
Output for 5.3.23
<pre>3738566 0.25291705131531
Output for 5.3.22
<pre>3738566 0.3103711605072
Output for 5.3.21
<pre>3738566 0.31014394760132
Output for 5.3.20
<pre>3738566 0.30119299888611
Output for 5.3.19
<pre>3738566 0.32409000396729
Output for 5.3.18
<pre>3738566 0.30342507362366
Output for 5.3.17
<pre>3738566 0.30379796028137
Output for 5.3.16
<pre>3738566 0.26790809631348
Output for 5.3.15
<pre>3738566 0.23439002037048
Output for 5.3.14
<pre>3738566 0.23724794387817
Output for 5.3.13
<pre>3738566 0.29419803619385
Output for 5.3.12
<pre>3738566 0.27689504623413
Output for 5.3.11
<pre>3738566 0.25987696647644
Output for 5.3.10
<pre>3738566 0.25091814994812
Output for 5.3.9
<pre>3738566 0.2334258556366
Output for 5.3.8
<pre>3738566 0.23460078239441
Output for 5.3.7
<pre>3738566 0.27912616729736
Output for 5.3.6
<pre>3738566 0.30348515510559
Output for 5.3.5
<pre>3738566 0.28399300575256
Output for 5.3.4
<pre>3738566 0.31388306617737
Output for 5.3.3
<pre>3738566 0.33296394348145
Output for 5.3.2
<pre>3738566 0.32809400558472
Output for 5.3.1
<pre>3738566 0.32876300811768
Output for 5.3.0
<pre>3738566 0.32662105560303
Output for 5.2.17
<pre>3738566 0.43961405754089
Output for 5.2.16
<pre>3738566 0.43520903587341
Output for 5.2.15
<pre>3738566 0.41830706596375
Output for 5.2.14
<pre>3738566 0.4554169178009
Output for 5.2.13
<pre>3738566 0.48592114448547
Output for 5.2.12
<pre>3738566 0.49826812744141
Output for 5.2.11
<pre>3738566 0.40919303894043
Output for 5.2.10
<pre>3738566 0.44552397727966
Output for 5.2.9
<pre>3738566 0.45973801612854
Output for 5.2.8
<pre>3738566 0.44539904594421
Output for 5.2.7
<pre>3738566 0.42990303039551
Output for 5.2.6
<pre>3738566 0.4468719959259
Output for 5.2.5
<pre>3738566 0.42650389671326
Output for 5.2.4
<pre>3738566 0.45750689506531
Output for 5.2.3
<pre>3738566 0.45017099380493
Output for 5.2.2
<pre>3738566 0.4227979183197
Output for 5.2.1
<pre>3738566 0.33119010925293
Output for 5.2.0
<pre>3738566 0.47675609588623
Output for 5.1.6
<pre>3738566 0.44219589233398
Output for 5.1.5
<pre>3738566 0.5245189666748
Output for 5.1.4
<pre>3738566 0.4822461605072
Output for 5.1.3
<pre>3738566 0.49198794364929
Output for 5.1.2
<pre>3738566 0.50145792961121
Output for 5.1.1
<pre>3738566 0.45910000801086
Output for 5.1.0
<pre>3738566 0.43843507766724
Output for 5.0.5
<pre>3738566 1.3097071647644
Output for 5.0.4
<pre>3738566 1.3565700054169
Output for 5.0.3
<pre>3738566 1.1670379638672
Output for 5.0.2
<pre>3738566 1.1146950721741
Output for 5.0.1
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL1.0948040485382
Output for 5.0.0
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL1.226487159729
Output for 4.4.9
<pre>3738566 0.325706
Output for 4.4.8
<pre>3738566 0.467554
Output for 4.4.7
<pre>3738566 0.395086
Output for 4.4.6
<pre>3738566 0.207311
Output for 4.4.5
<pre>3738566 0.195894
Output for 4.4.4
<pre>3738566 0.32287
Output for 4.4.3
<pre>3738566 0.230281
Output for 4.4.2
<pre>3738566 0.443068
Output for 4.4.1
<pre>3738566 0.37055
Output for 4.4.0
<pre>3738566 0.139927
Output for 4.3.11
<pre>3738566 0.315161
Output for 4.3.10
<pre>3738566 0.159758
Output for 4.3.9
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.084841
Output for 4.3.8
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.340957
Output for 4.3.7
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.35049
Output for 4.3.6
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.328702
Output for 4.3.5
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.277858
Output for 4.3.4
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.285595
Output for 4.3.3
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.311656
Output for 4.3.2
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.27866
Output for 4.3.1
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.096398
Output for 4.3.0
<pre>3738566 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/1u7Lu on line 22 PHP_EOL0.276785