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 = 10000; $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 8334 items memory usage 1317872 memory usage 1716096 took 0.23647999763489 sec finished with 6667 items
Output for 7.1.7
started with 8334 items memory usage 1281568 memory usage 1679792 took 0.23970508575439 sec finished with 6667 items
Output for 7.1.6
started with 8334 items memory usage 1282416 memory usage 1680640 took 0.24891495704651 sec finished with 6667 items
Output for 7.1.5
started with 8334 items memory usage 1282416 memory usage 1680640 took 0.24341702461243 sec finished with 6667 items
Output for 7.1.0
started with 8334 items memory usage 1281568 memory usage 1679792 took 0.14743494987488 sec finished with 6667 items
Output for 7.0.20
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.2219660282135 sec finished with 6667 items
Output for 7.0.14
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.18854999542236 sec finished with 6667 items
Output for 7.0.7
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.14737987518311 sec finished with 6667 items
Output for 7.0.6
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.22008395195007 sec finished with 6667 items
Output for 7.0.5
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.20225691795349 sec finished with 6667 items
Output for 7.0.4
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.19853210449219 sec finished with 6667 items
Output for 7.0.3
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.18291592597961 sec finished with 6667 items
Output for 7.0.2
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.18515491485596 sec finished with 6667 items
Output for 7.0.1
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.18086385726929 sec finished with 6667 items
Output for 7.0.0
started with 8334 items memory usage 1281528 memory usage 1680128 took 0.18875002861023 sec finished with 6667 items
Output for 5.6.28
started with 8334 items memory usage 2375912 memory usage 3451600 took 0.62756514549255 sec finished with 6667 items
Output for 5.6.21
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.91588306427 sec finished with 6667 items
Output for 5.6.20
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9347369670868 sec finished with 6667 items
Output for 5.6.19
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9132061004639 sec finished with 6667 items
Output for 5.6.18
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9349000453949 sec finished with 6667 items
Output for 5.6.17
started with 8334 items memory usage 2375912 memory usage 3451600 took 2.2437620162964 sec finished with 6667 items
Output for 5.6.16
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9566249847412 sec finished with 6667 items
Output for 5.6.15
started with 8334 items memory usage 2375912 memory usage 3451600 took 2.3320081233978 sec finished with 6667 items
Output for 5.6.14
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.8608479499817 sec finished with 6667 items
Output for 5.6.13
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9545071125031 sec finished with 6667 items
Output for 5.6.12
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9763140678406 sec finished with 6667 items
Output for 5.6.11
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9920649528503 sec finished with 6667 items
Output for 5.6.10
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9413261413574 sec finished with 6667 items
Output for 5.6.9
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.8702600002289 sec finished with 6667 items
Output for 5.6.8
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.9138557910919 sec finished with 6667 items
Output for 5.6.7
started with 8334 items memory usage 2375912 memory usage 3451600 took 1.8444969654083 sec finished with 6667 items
Output for 5.5.35
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.8374588489532 sec finished with 6667 items
Output for 5.5.34
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.93035197258 sec finished with 6667 items
Output for 5.5.33
started with 8334 items memory usage 2375664 memory usage 3451504 took 2.0264291763306 sec finished with 6667 items
Output for 5.5.32
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.9839940071106 sec finished with 6667 items
Output for 5.5.31
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.8359990119934 sec finished with 6667 items
Output for 5.5.30
started with 8334 items memory usage 2375664 memory usage 3451504 took 2.2989480495453 sec finished with 6667 items
Output for 5.5.29
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.9870579242706 sec finished with 6667 items
Output for 5.5.28
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.9944679737091 sec finished with 6667 items
Output for 5.5.27
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.9452769756317 sec finished with 6667 items
Output for 5.5.26
started with 8334 items memory usage 2375664 memory usage 3451504 took 2.0508790016174 sec finished with 6667 items
Output for 5.5.25
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.9633028507233 sec finished with 6667 items
Output for 5.5.24
started with 8334 items memory usage 2375664 memory usage 3451504 took 1.9975700378418 sec finished with 6667 items
Output for 5.4.10 - 5.4.26, 5.4.34 - 5.4.35, 5.4.38 - 5.4.39, 5.4.41 - 5.4.45
started with 8334 items memory usage 2376056
Process exited with code 137.
Output for 5.4.40
started with 8334 items memory usage 2376056 memory usage 3451768 took 2.427747964859 sec finished with 6667 items
Output for 5.4.37
started with 8334 items memory usage 2376056 memory usage 3451768 took 2.2177128791809 sec finished with 6667 items
Output for 5.4.36
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.9916541576385 sec finished with 6667 items
Output for 5.4.32
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.7444081306458 sec finished with 6667 items
Output for 5.4.31
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.7246868610382 sec finished with 6667 items
Output for 5.4.30
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.8001301288605 sec finished with 6667 items
Output for 5.4.29
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.7207610607147 sec finished with 6667 items
Output for 5.4.28
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.7706899642944 sec finished with 6667 items
Output for 5.4.27
started with 8334 items memory usage 2376056 memory usage 3451768 took 1.7438771724701 sec finished with 6667 items
Output for 5.4.0 - 5.4.9
started with 8334 items memory usage 2376120
Process exited with code 137.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/4pvOJ 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/4pvOJ 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/4pvOJ on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4pvOJ on line 5
Process exited with code 255.