3v4l.org

run code in 300+ PHP versions simultaneously
<?php // SETUP CODE class A { function __construct($val) { $this->val = $val; } } $objs = [ new A(3), new A(5), new A(2), ]; // AMAZING max_by IMPL :P function max_by(array $array, $key) { $res = array_filter($array, function($o) use($key) { static $m; $val = is_array($o) ? $o[$key] : $o->$key; $m = max($val, $m); return $val == $m; }); return end($res); } var_dump(max_by($objs, 'val'));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property A::$val is deprecated in /in/G4n09 on line 6 Deprecated: Creation of dynamic property A::$val is deprecated in /in/G4n09 on line 6 Deprecated: Creation of dynamic property A::$val is deprecated in /in/G4n09 on line 6 object(A)#2 (1) { ["val"]=> 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:
49.68 ms | 402 KiB | 8 Q