3v4l.org

run code in 200+ 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.2.0
started with 834 items memory usage 465904 memory usage 536448 took 0.0028538703918457 sec finished with 667 items
Output for 7.1.7
started with 834 items memory usage 429600 memory usage 500144 took 0.0018281936645508 sec finished with 667 items
Output for 7.1.6
started with 834 items memory usage 430448 memory usage 500992 took 0.0018298625946045 sec finished with 667 items
Output for 7.1.5
started with 834 items memory usage 430448 memory usage 500992 took 0.0021450519561768 sec finished with 667 items
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.20
started with 834 items memory usage 429560 memory usage 500480 took 0.0025420188903809 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 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.036426067352295 sec finished with 667 items
Output for 5.4.25
started with 834 items memory usage 429872 memory usage 552664 took 0.029095888137817 sec finished with 667 items
Output for 5.4.24
started with 834 items memory usage 429872 memory usage 552664 took 0.045109033584595 sec finished with 667 items
Output for 5.4.23
started with 834 items memory usage 429872 memory usage 552664 took 0.019195079803467 sec finished with 667 items
Output for 5.4.22
started with 834 items memory usage 429872 memory usage 552664 took 0.021718978881836 sec finished with 667 items
Output for 5.4.21
started with 834 items memory usage 429872 memory usage 552664 took 0.018990039825439 sec finished with 667 items
Output for 5.4.20
started with 834 items memory usage 429872 memory usage 552664 took 0.024526119232178 sec finished with 667 items
Output for 5.4.19
started with 834 items memory usage 429872 memory usage 552664 took 0.029067039489746 sec finished with 667 items
Output for 5.4.18
started with 834 items memory usage 429872 memory usage 552664 took 0.030061006546021 sec finished with 667 items
Output for 5.4.17
started with 834 items memory usage 429872 memory usage 552664 took 0.034186124801636 sec finished with 667 items
Output for 5.4.16
started with 834 items memory usage 429872 memory usage 552664 took 0.032002210617065 sec finished with 667 items
Output for 5.4.15
started with 834 items memory usage 429872 memory usage 552664 took 0.024662971496582 sec finished with 667 items
Output for 5.4.14
started with 834 items memory usage 429872 memory usage 552664 took 0.022055864334106 sec finished with 667 items
Output for 5.4.13
started with 834 items memory usage 429872 memory usage 552664 took 0.026844024658203 sec finished with 667 items
Output for 5.4.12
started with 834 items memory usage 429872 memory usage 552664 took 0.021475076675415 sec finished with 667 items
Output for 5.4.11
started with 834 items memory usage 429872 memory usage 552664 took 0.019604921340942 sec finished with 667 items
Output for 5.4.10
started with 834 items memory usage 429872 memory usage 552664 took 0.031136035919189 sec finished with 667 items
Output for 5.4.9
started with 834 items memory usage 429952 memory usage 552832 took 0.023383140563965 sec finished with 667 items
Output for 5.4.8
started with 834 items memory usage 429952 memory usage 552832 took 0.029613018035889 sec finished with 667 items
Output for 5.4.7
started with 834 items memory usage 429952 memory usage 552832 took 0.034280061721802 sec finished with 667 items
Output for 5.4.6
started with 834 items memory usage 429952 memory usage 552832 took 0.025923013687134 sec finished with 667 items
Output for 5.4.5
started with 834 items memory usage 429952 memory usage 552832 took 0.038213014602661 sec finished with 667 items
Output for 5.4.4
started with 834 items memory usage 429952 memory usage 552832 took 0.026188135147095 sec finished with 667 items
Output for 5.4.3
started with 834 items memory usage 429952 memory usage 552832 took 0.047637939453125 sec finished with 667 items
Output for 5.4.2
started with 834 items memory usage 429952 memory usage 552832 took 0.019331932067871 sec finished with 667 items
Output for 5.4.1
started with 834 items memory usage 429952 memory usage 552832 took 0.019661903381348 sec finished with 667 items
Output for 5.4.0
started with 834 items memory usage 429952 memory usage 552832 took 0.029225826263428 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.