3v4l.org

run code in 300+ PHP versions simultaneously
<?php class newsCollection { private $collection; private $keys = [ "headline", "date", "author", ]; public function __construct($data) { foreach ($data as &$el) { $el = array_combine($this->keys, $el); } $this->collection = $data; } public function getNewsCollection() { return $this->collection; } } $sports = [ [ "Boston Red Sox vs New York Yankees - 9-3", "19.06.2017", "ESPN" ], [ "Boston Patriot QB breaks new record!", "16.07.2017", "NESN" ], [ "Celtics coach John Doe inducted into hall of fame", "25.07.2017", "Fox Sports" ], [ "Boston Brewins win 16-5 against New York's Rangers", "21.08.2017", "NESN" ] ]; $c = new newsCollection($sports); var_dump($c->getNewsCollection());
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(3) { ["headline"]=> string(40) "Boston Red Sox vs New York Yankees - 9-3" ["date"]=> string(10) "19.06.2017" ["author"]=> string(4) "ESPN" } [1]=> array(3) { ["headline"]=> string(36) "Boston Patriot QB breaks new record!" ["date"]=> string(10) "16.07.2017" ["author"]=> string(4) "NESN" } [2]=> array(3) { ["headline"]=> string(49) "Celtics coach John Doe inducted into hall of fame" ["date"]=> string(10) "25.07.2017" ["author"]=> string(10) "Fox Sports" } [3]=> array(3) { ["headline"]=> string(50) "Boston Brewins win 16-5 against New York's Rangers" ["date"]=> string(10) "21.08.2017" ["author"]=> string(4) "NESN" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
156.33 ms | 407 KiB | 5 Q