3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataContainer implements IteratorAggregate { protected $data; public function __construct(array $data) { $this->data = $data; } public function &getIterator() { foreach ($this->data as $key => &$value) { yield $key => $value; } } } The class can then be iterated using by-ref foreach: $dataContainer = new DataContainer([1, 2, 3]); foreach ($dataContainer as &$value) { $value *= -1; } var_dump($dataContainer); // $this->data is now [-1, -2, -3]

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.220.0060.03812.40
5.4.210.0090.04312.40
5.4.200.0120.04112.40
5.4.190.0090.04212.39
5.4.180.0080.04312.39
5.4.170.0100.04212.40
5.4.160.0100.04112.39
5.4.150.0130.03912.39
5.4.140.0110.04112.08
5.4.130.0130.04112.06
5.4.120.0140.03812.03
5.4.110.0110.04212.03
5.4.100.0110.04212.03
5.4.90.0120.04112.03
5.4.80.0210.06112.03
5.4.70.0160.03612.02
5.4.60.0140.03612.02
5.4.50.0120.04112.02
5.4.40.0110.04112.01
5.4.30.0120.04112.01
5.4.20.0120.04112.00
5.4.10.0130.03912.01
5.4.00.0140.03811.50
5.3.270.0120.04512.72
5.3.260.0160.04112.72
5.3.250.0100.04412.72
5.3.240.0110.04312.72
5.3.230.0120.04312.71
5.3.220.0150.04012.68
5.3.210.0120.04512.68
5.3.200.0100.04512.68
5.3.190.0150.04012.68
5.3.180.0090.04612.67
5.3.170.0130.04012.67
5.3.160.0150.04212.68
5.3.150.0130.04312.67
5.3.140.0130.04512.66
5.3.130.0160.05812.66
5.3.120.0130.04412.66
5.3.110.0140.04312.66
5.3.100.0120.04212.12
5.3.90.0130.04212.10
5.3.80.0130.04112.09
5.3.70.0140.04112.08
5.3.60.0110.04212.07
5.3.50.0120.04212.02
5.3.40.0110.04312.01
5.3.30.0090.04311.98
5.3.20.0110.04011.76
5.3.10.0130.03911.72
5.3.00.0120.04111.71

preferences:
138.13 ms | 1394 KiB | 7 Q