3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function check_unique() { $seen = []; return function ($value) use (&$seen) { if (in_array($value, $seen)) { return false; } $seen[] = $value; return true; }; } const ITEMS = 1000; $array = array_merge(range(1, ITEMS, 3), range(1, ITEMS, 2)); echo "started with ", count($array), " items\n"; $check_unique = check_unique(); $unique = []; echo "memory usage ", memory_get_peak_usage(), "\n"; $time = -microtime(true); foreach ($array as $value) { if ($check_unique($value)) { $unique[] = $value; } } $time += microtime(true); echo "memory usage ", memory_get_peak_usage(), "\n"; echo "took $time sec\n"; echo "finished with ", count($unique), " items\n";
Output for 7.1.0
started with 834 items memory usage 429512 memory usage 463032 took 0.00032305717468262 sec finished with 667 items
Output for 7.0.14
started with 834 items memory usage 429536 memory usage 463432 took 0.00061511993408203 sec finished with 667 items
Output for 7.0.6
started with 834 items memory usage 429536 memory usage 463432 took 0.00050210952758789 sec finished with 667 items
Output for 7.0.5
started with 834 items memory usage 429536 memory usage 463432 took 0.00052809715270996 sec finished with 667 items
Output for 7.0.4
started with 834 items memory usage 429536 memory usage 463432 took 0.00033903121948242 sec finished with 667 items
Output for 7.0.3
started with 834 items memory usage 429536 memory usage 463432 took 0.00032591819763184 sec finished with 667 items
Output for 7.0.2
started with 834 items memory usage 429536 memory usage 463432 took 0.00044703483581543 sec finished with 667 items
Output for 7.0.1
started with 834 items memory usage 429536 memory usage 463432 took 0.00041699409484863 sec finished with 667 items
Output for 7.0.0
started with 834 items memory usage 429536 memory usage 463432 took 0.0004429817199707 sec finished with 667 items
Output for 5.6.28
started with 834 items memory usage 429528 memory usage 552376 took 0.018115997314453 sec finished with 667 items
Output for 5.6.21
started with 834 items memory usage 429528 memory usage 552376 took 0.011208057403564 sec finished with 667 items
Output for 5.6.20
started with 834 items memory usage 429528 memory usage 552376 took 0.015887975692749 sec finished with 667 items
Output for 5.6.19
started with 834 items memory usage 429528 memory usage 552376 took 0.014019012451172 sec finished with 667 items
Output for 5.6.18
started with 834 items memory usage 429528 memory usage 552376 took 0.0097579956054688 sec finished with 667 items
Output for 5.6.17
started with 834 items memory usage 429528 memory usage 552376 took 0.010056018829346 sec finished with 667 items
Output for 5.6.16
started with 834 items memory usage 429528 memory usage 552376 took 0.016112089157104 sec finished with 667 items
Output for 5.6.15
started with 834 items memory usage 429528 memory usage 552376 took 0.013540983200073 sec finished with 667 items
Output for 5.6.14
started with 834 items memory usage 429528 memory usage 552376 took 0.014580011367798 sec finished with 667 items
Output for 5.6.13
started with 834 items memory usage 429528 memory usage 552376 took 0.015425205230713 sec finished with 667 items
Output for 5.6.12
started with 834 items memory usage 429528 memory usage 552376 took 0.013234853744507 sec finished with 667 items
Output for 5.6.11
started with 834 items memory usage 429528 memory usage 552376 took 0.011182069778442 sec finished with 667 items
Output for 5.6.10
started with 834 items memory usage 429528 memory usage 552376 took 0.016731977462769 sec finished with 667 items
Output for 5.6.9
started with 834 items memory usage 429528 memory usage 552376 took 0.014876842498779 sec finished with 667 items
Output for 5.6.8
started with 834 items memory usage 429528 memory usage 552376 took 0.01493501663208 sec finished with 667 items
Output for 5.5.35
started with 834 items memory usage 429256 memory usage 552120 took 0.016947031021118 sec finished with 667 items
Output for 5.5.34
started with 834 items memory usage 429256 memory usage 552120 took 0.018757820129395 sec finished with 667 items
Output for 5.5.33
started with 834 items memory usage 429256 memory usage 552120 took 0.011976957321167 sec finished with 667 items
Output for 5.5.32
started with 834 items memory usage 429256 memory usage 552120 took 0.016851186752319 sec finished with 667 items
Output for 5.5.31
started with 834 items memory usage 429256 memory usage 552120 took 0.015403985977173 sec finished with 667 items
Output for 5.5.30
started with 834 items memory usage 429256 memory usage 552120 took 0.016868114471436 sec finished with 667 items
Output for 5.5.29
started with 834 items memory usage 429256 memory usage 552120 took 0.017095804214478 sec finished with 667 items
Output for 5.5.28
started with 834 items memory usage 429256 memory usage 552120 took 0.010650873184204 sec finished with 667 items
Output for 5.5.27
started with 834 items memory usage 429256 memory usage 552120 took 0.015530109405518 sec finished with 667 items
Output for 5.5.26
started with 834 items memory usage 429256 memory usage 552120 took 0.016185998916626 sec finished with 667 items
Output for 5.5.25
started with 834 items memory usage 429256 memory usage 552120 took 0.015408039093018 sec finished with 667 items
Output for 5.5.24
started with 834 items memory usage 429256 memory usage 552120 took 0.018023014068604 sec finished with 667 items
Output for 5.4.45
started with 834 items memory usage 429640 memory usage 552320 took 0.018546104431152 sec finished with 667 items
Output for 5.4.44
started with 834 items memory usage 429640 memory usage 552320 took 0.019354104995728 sec finished with 667 items
Output for 5.4.43
started with 834 items memory usage 429640 memory usage 552320 took 0.0091779232025146 sec finished with 667 items
Output for 5.4.42
started with 834 items memory usage 429640 memory usage 552320 took 0.009774923324585 sec finished with 667 items
Output for 5.4.41
started with 834 items memory usage 429640 memory usage 552320 took 0.015726089477539 sec finished with 667 items
Output for 5.4.40
started with 834 items memory usage 429640 memory usage 552320 took 0.0095241069793701 sec finished with 667 items
Output for 5.4.39
started with 834 items memory usage 429640 memory usage 552320 took 0.0085349082946777 sec finished with 667 items
Output for 5.4.38
started with 834 items memory usage 429640 memory usage 552320 took 0.020380020141602 sec finished with 667 items
Output for 5.4.37
started with 834 items memory usage 429640 memory usage 552320 took 0.029211044311523 sec finished with 667 items
Output for 5.4.36
started with 834 items memory usage 429640 memory usage 552320 took 0.028664112091064 sec finished with 667 items
Output for 5.4.35
started with 834 items memory usage 429640 memory usage 552320 took 0.032068014144897 sec finished with 667 items
Output for 5.4.34
started with 834 items memory usage 429640 memory usage 552320 took 0.033834218978882 sec finished with 667 items
Output for 5.4.32
started with 834 items memory usage 429640 memory usage 552320 took 0.010879039764404 sec finished with 667 items
Output for 5.4.31
started with 834 items memory usage 429640 memory usage 552320 took 0.011354923248291 sec finished with 667 items
Output for 5.4.30
started with 834 items memory usage 429640 memory usage 552320 took 0.010710000991821 sec finished with 667 items
Output for 5.4.29
started with 834 items memory usage 429640 memory usage 552320 took 0.01073694229126 sec finished with 667 items
Output for 5.4.28
started with 834 items memory usage 429640 memory usage 552320 took 0.018563032150269 sec finished with 667 items
Output for 5.4.27
started with 834 items memory usage 429640 memory usage 552320 took 0.010737895965576 sec finished with 667 items
Output for 5.4.26
started with 834 items memory usage 429640 memory usage 552320 took 0.013741016387939 sec finished with 667 items
Output for 5.4.25
started with 834 items memory usage 429640 memory usage 552320 took 0.023503065109253 sec finished with 667 items
Output for 5.4.24
started with 834 items memory usage 429640 memory usage 552320 took 0.022362947463989 sec finished with 667 items
Output for 5.4.23
started with 834 items memory usage 429640 memory usage 552320 took 0.022036075592041 sec finished with 667 items
Output for 5.4.22
started with 834 items memory usage 429640 memory usage 552320 took 0.021839141845703 sec finished with 667 items
Output for 5.4.21
started with 834 items memory usage 429640 memory usage 552320 took 0.022135019302368 sec finished with 667 items
Output for 5.4.20
started with 834 items memory usage 429640 memory usage 552320 took 0.013019800186157 sec finished with 667 items
Output for 5.4.19
started with 834 items memory usage 429640 memory usage 552320 took 0.011602163314819 sec finished with 667 items
Output for 5.4.18
started with 834 items memory usage 429640 memory usage 552320 took 0.012041091918945 sec finished with 667 items
Output for 5.4.17
started with 834 items memory usage 429640 memory usage 552320 took 0.011550903320312 sec finished with 667 items
Output for 5.4.16
started with 834 items memory usage 429640 memory usage 552320 took 0.015028953552246 sec finished with 667 items
Output for 5.4.15
started with 834 items memory usage 429640 memory usage 552320 took 0.011009931564331 sec finished with 667 items
Output for 5.4.14
started with 834 items memory usage 429640 memory usage 552320 took 0.011821985244751 sec finished with 667 items
Output for 5.4.13
started with 834 items memory usage 429640 memory usage 552320 took 0.011817932128906 sec finished with 667 items
Output for 5.4.12
started with 834 items memory usage 429640 memory usage 552320 took 0.015094995498657 sec finished with 667 items
Output for 5.4.11
started with 834 items memory usage 429640 memory usage 552320 took 0.019830942153931 sec finished with 667 items
Output for 5.4.10
started with 834 items memory usage 429640 memory usage 552320 took 0.01753306388855 sec finished with 667 items
Output for 5.4.9
started with 834 items memory usage 429720 memory usage 552392 took 0.019851922988892 sec finished with 667 items
Output for 5.4.8
started with 834 items memory usage 429720 memory usage 552392 took 0.019705057144165 sec finished with 667 items
Output for 5.4.7
started with 834 items memory usage 429720 memory usage 552392 took 0.011322975158691 sec finished with 667 items
Output for 5.4.6
started with 834 items memory usage 429720 memory usage 552392 took 0.01289701461792 sec finished with 667 items
Output for 5.4.5
started with 834 items memory usage 429720 memory usage 552392 took 0.015809059143066 sec finished with 667 items
Output for 5.4.4
started with 834 items memory usage 429720 memory usage 552392 took 0.016379117965698 sec finished with 667 items
Output for 5.4.3
started with 834 items memory usage 429720 memory usage 552392 took 0.01962685585022 sec finished with 667 items
Output for 5.4.2
started with 834 items memory usage 429720 memory usage 552392 took 0.020796060562134 sec finished with 667 items
Output for 5.4.1
started with 834 items memory usage 429720 memory usage 552392 took 0.020994186401367 sec finished with 667 items
Output for 5.4.0
started with 834 items memory usage 429720 memory usage 552392 took 0.021086931228638 sec finished with 667 items
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/nUgYf on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/nUgYf on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/nUgYf on line 4
Process exited with code 255.