3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Weakmaps accepts objects and arrays as keys $source = new Weakmap(); $key = (object) ['a' => 2]; $source[$key] = 1; // Yield may emit objects and arrays as keys $source = function () { yield (object) ['a' => 3] => 1; }; // This is just for illustration $source = $source(); // An iterator may return objects and arrays as keys(mixed, in fact) class myIterator implements Iterator { private int $position = 0; public function rewind(): void { $this->position = 0; } public function current(): mixed { return 1; } public function key(): mixed { return (object) ['a' => 4]; } public function next(): void { ++$this->position; } public function valid(): bool { return $this->position == 0; } } $source = new myIterator(); foreach($source as $key => $value) { print get_class($key); // Stdclass print $value; // 1 }

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)
8.5.90.0070.00117.04
8.5.80.0260.00916.80
8.5.70.0360.01417.10
8.5.60.0340.01116.78
8.5.50.0290.00616.73
8.5.40.0300.00616.57
8.5.30.0290.00516.65
8.5.20.0310.00716.36
8.5.10.0400.01116.44
8.5.00.0100.00816.75
8.4.240.0090.01419.67
8.4.230.0290.00319.47
8.4.220.0200.01519.77
8.4.210.0330.01219.54
8.4.200.0360.00919.42
8.4.190.0370.00619.82
8.4.180.0300.01419.59
8.4.170.0310.01219.61
8.4.160.0300.01319.76
8.4.150.0320.01019.65
8.4.140.0330.01017.25
8.4.130.0400.00417.75
8.4.120.0380.00618.00
8.4.110.0350.00917.88
8.4.100.0360.01017.88
8.4.90.0380.01017.82
8.4.80.0350.00917.86
8.4.70.0390.00717.88
8.4.60.0350.01217.91
8.4.50.0360.01217.79
8.4.40.0380.00917.84
8.4.30.0290.00317.75
8.4.20.0400.00817.83
8.4.10.0440.00517.85
8.3.330.0100.01118.65
8.3.320.0420.00718.36
8.3.310.0300.01418.25
8.3.300.0310.01018.30
8.3.290.0340.00718.38
8.3.280.0320.00518.46
8.3.270.0350.00816.66
8.3.260.0320.01216.84
8.3.250.0390.00616.64
8.3.240.0280.01216.73
8.3.230.0330.00916.79
8.3.220.0340.00816.56
8.3.210.0350.00716.84
8.3.200.0410.00816.75
8.3.190.0350.00716.79
8.3.180.0320.01016.76
8.3.170.0360.00916.69
8.3.160.0390.00616.80
8.3.150.0370.00416.78
8.3.140.0340.01116.79
8.3.130.0240.00516.86
8.3.120.0330.00516.54
8.3.110.0320.01216.63
8.3.100.0240.00716.77
8.3.90.0350.00816.73
8.3.80.0360.00816.73
8.3.70.0320.00516.74
8.3.60.0330.00916.41
8.3.50.0330.00916.56
8.3.40.0370.01018.05
8.3.30.0280.01017.82
8.3.20.0300.00618.04
8.3.10.0250.01018.05
8.3.00.0300.00517.75
8.2.320.0490.01217.95
8.2.310.0320.01017.82

preferences:
54.84 ms | 774 KiB | 5 Q