3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_map_via_callback($f, $a) { $o = []; $c = function ($v) use (&$o) { $o[] = $v; }; foreach ($a as $k => $v) $f($v, $c); return $o; } // Mapping $x => $x ^ 2 function forClassicMap($x) { return $x * $x; } $mapped1 = array_map('forClassicMap', [1, 2, 3]); // Mapping $x => $x ^ 2 via callback function forMapViaCallback($x, $callback) { $callback($x * $x); } $mapped2 = array_map_via_callback('forMapViaCallback', [1, 2, 3]); var_dump($mapped1, $mapped2);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> int(1) [1]=> int(4) [2]=> int(9) } array(3) { [0]=> int(1) [1]=> int(4) [2]=> int(9) }

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:
47.29 ms | 401 KiB | 8 Q