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
array_filter: 0.025263071060181 foreach: 0.011181116104126 for i: 0.013171911239624
Output for git.master
array_filter: 0.029149055480957 foreach: 0.011549949645996 for i: 0.013271808624268
Output for rfc.property-hooks
array_filter: 0.038850069046021 foreach: 0.011744976043701 for i: 0.014303922653198

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:
37.24 ms | 408 KiB | 5 Q