3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function check_unique() { $seen = new ArrayObject(); return function ($value) use ($seen) { if (in_array($value, (array)$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 429600 memory usage 500144 took 0.0015079975128174 sec finished with 667 items
Output for 7.0.14
started with 834 items memory usage 429560 memory usage 500480 took 0.0020930767059326 sec finished with 667 items
Output for 7.0.6
started with 834 items memory usage 429560 memory usage 500480 took 0.0020630359649658 sec finished with 667 items
Output for 7.0.5
started with 834 items memory usage 429560 memory usage 500480 took 0.0015501976013184 sec finished with 667 items
Output for 7.0.4
started with 834 items memory usage 429560 memory usage 500480 took 0.0017828941345215 sec finished with 667 items
Output for 7.0.3
started with 834 items memory usage 429560 memory usage 500480 took 0.0013101100921631 sec finished with 667 items
Output for 7.0.2
started with 834 items memory usage 429560 memory usage 500480 took 0.0017139911651611 sec finished with 667 items
Output for 7.0.1
started with 834 items memory usage 429560 memory usage 500480 took 0.001823902130127 sec finished with 667 items
Output for 7.0.0
started with 834 items memory usage 429560 memory usage 500480 took 0.0016849040985107 sec finished with 667 items
Output for hhvm-3.12.0
started with 834 items memory usage 2097152 memory usage 2097152 took 0.0027430057525635 sec finished with 667 items
Output for hhvm-3.10.0
started with 834 items memory usage 2097152 memory usage 2097152 took 0.0030620098114014 sec finished with 667 items
Output for 5.6.28
started with 834 items memory usage 429720 memory usage 552808 took 0.021255016326904 sec finished with 667 items
Output for 5.6.21
started with 834 items memory usage 429720 memory usage 552808 took 0.017927885055542 sec finished with 667 items
Output for 5.6.20
started with 834 items memory usage 429720 memory usage 552808 took 0.012756824493408 sec finished with 667 items
Output for 5.6.19
started with 834 items memory usage 429720 memory usage 552808 took 0.015302896499634 sec finished with 667 items
Output for 5.6.18
started with 834 items memory usage 429720 memory usage 552808 took 0.013669967651367 sec finished with 667 items
Output for 5.6.17
started with 834 items memory usage 429720 memory usage 552808 took 0.013697147369385 sec finished with 667 items
Output for 5.6.16
started with 834 items memory usage 429720 memory usage 552808 took 0.020272970199585 sec finished with 667 items
Output for 5.6.15
started with 834 items memory usage 429720 memory usage 552808 took 0.013222217559814 sec finished with 667 items
Output for 5.6.14
started with 834 items memory usage 429720 memory usage 552808 took 0.013126850128174 sec finished with 667 items
Output for 5.6.13
started with 834 items memory usage 429720 memory usage 552808 took 0.017946004867554 sec finished with 667 items
Output for 5.6.12
started with 834 items memory usage 429720 memory usage 552808 took 0.018350839614868 sec finished with 667 items
Output for 5.6.11
started with 834 items memory usage 429720 memory usage 552808 took 0.01625394821167 sec finished with 667 items
Output for 5.6.10
started with 834 items memory usage 429720 memory usage 552808 took 0.014652967453003 sec finished with 667 items
Output for 5.6.9
started with 834 items memory usage 429720 memory usage 552808 took 0.018639087677002 sec finished with 667 items
Output for 5.6.8
started with 834 items memory usage 429720 memory usage 552808 took 0.018092155456543 sec finished with 667 items
Output for 5.5.35
started with 834 items memory usage 429480 memory usage 552456 took 0.018607139587402 sec finished with 667 items
Output for 5.5.34
started with 834 items memory usage 429480 memory usage 552456 took 0.015614032745361 sec finished with 667 items
Output for 5.5.33
started with 834 items memory usage 429480 memory usage 552456 took 0.012846946716309 sec finished with 667 items
Output for 5.5.32
started with 834 items memory usage 429480 memory usage 552456 took 0.015851974487305 sec finished with 667 items
Output for 5.5.31
started with 834 items memory usage 429480 memory usage 552456 took 0.017575025558472 sec finished with 667 items
Output for 5.5.30
started with 834 items memory usage 429480 memory usage 552456 took 0.0174880027771 sec finished with 667 items
Output for 5.5.29
started with 834 items memory usage 429480 memory usage 552456 took 0.021683931350708 sec finished with 667 items
Output for 5.5.28
started with 834 items memory usage 429480 memory usage 552456 took 0.019497156143188 sec finished with 667 items
Output for 5.5.27
started with 834 items memory usage 429480 memory usage 552456 took 0.021114826202393 sec finished with 667 items
Output for 5.5.26
started with 834 items memory usage 429480 memory usage 552456 took 0.01375412940979 sec finished with 667 items
Output for 5.5.25
started with 834 items memory usage 429480 memory usage 552456 took 0.017177104949951 sec finished with 667 items
Output for 5.5.24
started with 834 items memory usage 429480 memory usage 552456 took 0.013245105743408 sec finished with 667 items
Output for 5.4.45
started with 834 items memory usage 429872 memory usage 552664 took 0.02523398399353 sec finished with 667 items
Output for 5.4.44
started with 834 items memory usage 429872 memory usage 552664 took 0.028260946273804 sec finished with 667 items
Output for 5.4.43
started with 834 items memory usage 429872 memory usage 552664 took 0.011293888092041 sec finished with 667 items
Output for 5.4.42
started with 834 items memory usage 429872 memory usage 552664 took 0.010684967041016 sec finished with 667 items
Output for 5.4.41
started with 834 items memory usage 429872 memory usage 552664 took 0.022255897521973 sec finished with 667 items
Output for 5.4.40
started with 834 items memory usage 429872 memory usage 552664 took 0.036932945251465 sec finished with 667 items
Output for 5.4.39
started with 834 items memory usage 429872 memory usage 552664 took 0.013581991195679 sec finished with 667 items
Output for 5.4.38
started with 834 items memory usage 429872 memory usage 552664 took 0.017683029174805 sec finished with 667 items
Output for 5.4.37
started with 834 items memory usage 429872 memory usage 552664 took 0.01859712600708 sec finished with 667 items
Output for 5.4.36
started with 834 items memory usage 429872 memory usage 552664 took 0.023787975311279 sec finished with 667 items
Output for 5.4.35
started with 834 items memory usage 429872 memory usage 552664 took 0.025840997695923 sec finished with 667 items
Output for 5.4.34
started with 834 items memory usage 429872 memory usage 552664 took 0.030813932418823 sec finished with 667 items
Output for 5.4.32
started with 834 items memory usage 429872 memory usage 552664 took 0.013754844665527 sec finished with 667 items
Output for 5.4.31
started with 834 items memory usage 429872 memory usage 552664 took 0.013410806655884 sec finished with 667 items
Output for 5.4.30
started with 834 items memory usage 429872 memory usage 552664 took 0.014400005340576 sec finished with 667 items
Output for 5.4.29
started with 834 items memory usage 429872 memory usage 552664 took 0.01299786567688 sec finished with 667 items
Output for 5.4.28
started with 834 items memory usage 429872 memory usage 552664 took 0.022500038146973 sec finished with 667 items
Output for 5.4.27
started with 834 items memory usage 429872 memory usage 552664 took 0.013295888900757 sec finished with 667 items
Output for 5.4.26
started with 834 items memory usage 429872 memory usage 552664 took 0.016691207885742 sec finished with 667 items
Output for 5.4.25
started with 834 items memory usage 429872 memory usage 552664 took 0.016293048858643 sec finished with 667 items
Output for 5.4.24
started with 834 items memory usage 429872 memory usage 552664 took 0.015791893005371 sec finished with 667 items
Output for 5.4.23
started with 834 items memory usage 429872 memory usage 552664 took 0.02409815788269 sec finished with 667 items
Output for 5.4.22
started with 834 items memory usage 429872 memory usage 552664 took 0.023977994918823 sec finished with 667 items
Output for 5.4.21
started with 834 items memory usage 429872 memory usage 552664 took 0.018839120864868 sec finished with 667 items
Output for 5.4.20
started with 834 items memory usage 429872 memory usage 552664 took 0.015482902526855 sec finished with 667 items
Output for 5.4.19
started with 834 items memory usage 429872 memory usage 552664 took 0.015365123748779 sec finished with 667 items
Output for 5.4.18
started with 834 items memory usage 429872 memory usage 552664 took 0.01655387878418 sec finished with 667 items
Output for 5.4.17
started with 834 items memory usage 429872 memory usage 552664 took 0.016716957092285 sec finished with 667 items
Output for 5.4.16
started with 834 items memory usage 429872 memory usage 552664 took 0.02326512336731 sec finished with 667 items
Output for 5.4.15
started with 834 items memory usage 429872 memory usage 552664 took 0.016433000564575 sec finished with 667 items
Output for 5.4.14
started with 834 items memory usage 429872 memory usage 552664 took 0.01594090461731 sec finished with 667 items
Output for 5.4.13
started with 834 items memory usage 429872 memory usage 552664 took 0.016024827957153 sec finished with 667 items
Output for 5.4.12
started with 834 items memory usage 429872 memory usage 552664 took 0.016290903091431 sec finished with 667 items
Output for 5.4.11
started with 834 items memory usage 429872 memory usage 552664 took 0.016652822494507 sec finished with 667 items
Output for 5.4.10
started with 834 items memory usage 429872 memory usage 552664 took 0.016119956970215 sec finished with 667 items
Output for 5.4.9
started with 834 items memory usage 429952 memory usage 552832 took 0.015697002410889 sec finished with 667 items
Output for 5.4.8
started with 834 items memory usage 429952 memory usage 552832 took 0.016932964324951 sec finished with 667 items
Output for 5.4.7
started with 834 items memory usage 429952 memory usage 552832 took 0.015022993087769 sec finished with 667 items
Output for 5.4.6
started with 834 items memory usage 429952 memory usage 552832 took 0.017186164855957 sec finished with 667 items
Output for 5.4.5
started with 834 items memory usage 429952 memory usage 552832 took 0.019064903259277 sec finished with 667 items
Output for 5.4.4
started with 834 items memory usage 429952 memory usage 552832 took 0.026634216308594 sec finished with 667 items
Output for 5.4.3
started with 834 items memory usage 429952 memory usage 552832 took 0.025922060012817 sec finished with 667 items
Output for 5.4.2
started with 834 items memory usage 429952 memory usage 552832 took 0.025819063186646 sec finished with 667 items
Output for 5.4.1
started with 834 items memory usage 429952 memory usage 552832 took 0.025891780853271 sec finished with 667 items
Output for 5.4.0
started with 834 items memory usage 429952 memory usage 552832 took 0.023111820220947 sec finished with 667 items
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/kKf60 on line 19
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/kKf60 on line 5
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 T_FUNCTION in /in/kKf60 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/kKf60 on line 5
Process exited with code 255.