3v4l.org

run code in 300+ PHP versions simultaneously
<?php function max_by($collection, $property) { $plucked = array_map(function ($item) use ($property) { return $item->$property; }, $collection); return max($plucked); } class A { function __construct($u,$v) { $this->u = $u; $this->v = $v; } } $array = [ new A(1,5), new A(2,2), new A(3,1) ]; $a = max_by($array, 'u'); $b = max_by($array, 'v'); var_dump($a, $b);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property A::$u is deprecated in /in/u26tp on line 12 Deprecated: Creation of dynamic property A::$v is deprecated in /in/u26tp on line 13 Deprecated: Creation of dynamic property A::$u is deprecated in /in/u26tp on line 12 Deprecated: Creation of dynamic property A::$v is deprecated in /in/u26tp on line 13 Deprecated: Creation of dynamic property A::$u is deprecated in /in/u26tp on line 12 Deprecated: Creation of dynamic property A::$v is deprecated in /in/u26tp on line 13 int(3) int(5)

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:
48.56 ms | 402 KiB | 8 Q