3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection { private $a = array(); public function __construct() { for ($i = 0; $i < 100000; $i++) { $this->a[] = $i; } } public function all() { return $this->a; } } $coll = new Collection(); $start = microtime(true); foreach ($coll->all() as $k => $v) { $a[$k] = $v + 1; } echo "Completed in ", microtime(true) - $start, " Seconds\n"; $start = microtime(true); $arr = $coll->all(); foreach ($arr as $k => &$v) { $v = $v + 1; } echo "Completed in ", microtime(true) - $start, " Seconds\n";

preferences:
32.68 ms | 402 KiB | 5 Q