3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*** Results on my machine *** php 7.2 array_filter: 2.5147440433502 foreach: 0.13733291625977 for i: 0.24090600013733 php 7.4 array_filter: 0.057109117507935 foreach: 0.021071910858154 for i: 0.027867078781128 **/ ini_set('memory_limit', '500M'); $data = range(0, 1000000); // ARRAY FILTER $start = microtime(true); $newData = array_filter($data, function ($item) { return $item % 2; }); $end = microtime(true); echo "array_filter: "; echo $end - $start . PHP_EOL; // FOREACH $start = microtime(true); $newData = array(); foreach ($data as $item) { if ($item % 2) { $newData[] = $item; } } $end = microtime(true); echo "foreach: "; echo $end - $start . PHP_EOL; // FOR $start = microtime(true); $newData = array(); $numItems = count($data); for ($i = 0; $i < $numItems; $i++) { if ($data[$i] % 2) { $newData[] = $data[$i]; } } $end = microtime(true); echo "for i: "; echo $end - $start . PHP_EOL;
Output for git.master_jit
Fatal error: Out of memory (allocated 26218496 bytes) (tried to allocate 10485760 bytes) in /in/Zit6P on line 19 Stack trace: #0 /in/Zit6P(19): array_filter(Array, Object(Closure)) #1 {main} mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for git.master
Fatal error: Out of memory (allocated 31461376 bytes) (tried to allocate 20971520 bytes) in /in/Zit6P on line 19 Stack trace: #0 /in/Zit6P(19): array_filter(Array, Object(Closure)) #1 {main} mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for rfc.property-hooks
array_filter: 0.077615022659302 foreach: 0.011981964111328 for i: 0.014287948608398

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
64.24 ms | 1556 KiB | 4 Q