3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $foo = []; function add($name, $value, $priority = 500) { $this->foo[$name][$priority][] = $value; } public function get() { return $this->foo; } } $foo = new Foo; $foo->add('foo', 'a'); $foo->add('foo', 'a', 1000); $foo->add('foo', 'b'); $foo->add('foo', 'c', 0); $foo->add('foo', 'd', 23); var_dump($foo->get());
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
array(1) { ["foo"]=> array(4) { [500]=> array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } [1000]=> array(1) { [0]=> string(1) "a" } [0]=> array(1) { [0]=> string(1) "c" } [23]=> array(1) { [0]=> string(1) "d" } } }

preferences:
190.91 ms | 405 KiB | 167 Q