3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array(); for ($i = 0; $i < 200000; $i++) { $a[] = array( 'name' => 'John', 'city' => 'New York', 'age' => $i % 200 == 0 ? 21 : 28 ); } $time = microtime(true); $filtered = array(); foreach ($a as $item) { if ($item['age'] == 21) $filtered[] = $item; } $time = microtime(true) - $time; echo 'explicit foreach ' . number_format($time, 3) . ' seconds and returned ' . count($filtered) . " entries\n";
based on sX8ZF
Output for 7.0.0 - 7.1.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4096 bytes) in /in/CjIMW on line 5
Process exited with code 255.
Output for hhvm-3.12.0
explicit foreach 0.016 seconds and returned 1000 entries
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.5.24 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/CjIMW on line 9
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/CjIMW on line 9
Process exited with code 255.
Output for 5.4.0 - 5.4.9
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 64 bytes) in /in/CjIMW on line 8
Process exited with code 255.
Output for 5.2.1, 5.2.7 - 5.2.9, 5.3.11 - 5.3.29
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 76 bytes) in /in/CjIMW on line 9
Process exited with code 255.
Output for 5.3.0 - 5.3.10
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/CjIMW on line 7
Process exited with code 255.
Output for 5.2.10 - 5.2.17
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /in/CjIMW on line 11
Process exited with code 255.
Output for 5.2.6
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /in/CjIMW on line 8
Process exited with code 255.
Output for 5.2.3 - 5.2.5
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 5 bytes) in /in/CjIMW on line 8
Process exited with code 255.
Output for 5.2.2
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 75 bytes) in /in/CjIMW on line 11
Process exited with code 255.
Output for 5.2.0
explicit foreach 0.028 seconds and returned 1000 entries
Output for 5.1.6
explicit foreach 0.033 seconds and returned 1000 entries
Output for 5.1.5
explicit foreach 0.040 seconds and returned 1000 entries
Output for 5.1.4
explicit foreach 0.037 seconds and returned 1000 entries
Output for 5.1.3
explicit foreach 0.035 seconds and returned 1000 entries
Output for 5.1.2
explicit foreach 0.055 seconds and returned 1000 entries
Output for 5.1.1
explicit foreach 0.036 seconds and returned 1000 entries
Output for 5.1.0
explicit foreach 0.039 seconds and returned 1000 entries
Output for 5.0.5
explicit foreach 0.080 seconds and returned 1000 entries
Output for 5.0.4
explicit foreach 0.068 seconds and returned 1000 entries
Output for 4.3.8, 5.0.3
explicit foreach 0.074 seconds and returned 1000 entries
Output for 4.4.5, 5.0.2
explicit foreach 0.088 seconds and returned 1000 entries
Output for 5.0.1
explicit foreach 0.076 seconds and returned 1000 entries
Output for 5.0.0
explicit foreach 0.075 seconds and returned 1000 entries
Output for 4.4.4, 4.4.9
explicit foreach 0.097 seconds and returned 1000 entries
Output for 4.4.8
explicit foreach -0.903 seconds and returned 1000 entries
Output for 4.4.7
explicit foreach 0.079 seconds and returned 1000 entries
Output for 4.4.6
explicit foreach 0.093 seconds and returned 1000 entries
Output for 4.4.3
explicit foreach 0.086 seconds and returned 1000 entries
Output for 4.4.2
explicit foreach 0.112 seconds and returned 1000 entries
Output for 4.4.1
explicit foreach -0.894 seconds and returned 1000 entries
Output for 4.4.0
explicit foreach 0.102 seconds and returned 1000 entries
Output for 4.3.11
explicit foreach 0.084 seconds and returned 1000 entries
Output for 4.3.10
explicit foreach 0.095 seconds and returned 1000 entries
Output for 4.3.9
explicit foreach 0.082 seconds and returned 1000 entries
Output for 4.3.7
explicit foreach 0.094 seconds and returned 1000 entries
Output for 4.3.6
explicit foreach -0.917 seconds and returned 1000 entries
Output for 4.3.5
explicit foreach 0.106 seconds and returned 1000 entries
Output for 4.3.4
explicit foreach 0.098 seconds and returned 1000 entries
Output for 4.3.3
explicit foreach 0.085 seconds and returned 1000 entries
Output for 4.3.2
explicit foreach 0.073 seconds and returned 1000 entries
Output for 4.3.1
explicit foreach 0.103 seconds and returned 1000 entries
Output for 4.3.0
explicit foreach 0.152 seconds and returned 1000 entries