3v4l.org

run code in 300+ PHP versions simultaneously
<?php function compose(/* funs to compose */) { $fl = func_get_args(); return function($x) use($fl) { $val = $x; while (null !== $f = array_pop($fl)) { $val = $f($val); }; return $val; }; } $up = function($s) {return strtoupper($s);}; $y = function($s) {return $s.'!';}; $reverse = function($a) {return array_reverse($a);}; $head = function($a) {return array_shift(array_values($a));}; $data = ['jumpkick', 'roundhouse', 'uppercut']; $c = compose($y, $up, $head, $reverse); var_dump($c($data));

preferences:
56.72 ms | 402 KiB | 5 Q