3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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());
based on TbP8U
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.1.7
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" } } }