3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['a' => 1, 'b' => 2], ['a' => 2, 'b' => 2] ]; $data = new stdClass(); $data->count = 0; $data->a = 0; $data->b = 0; var_dump($data); $cb = function($value, $key, &$data) { $data->count = $data->count + 1; $data->a = $data->a + $value['a']; $data->b = $data->b + $value['b']; }; array_walk($array, $cb, $data);
Output for git.master, git.master_jit, rfc.property-hooks
object(stdClass)#1 (3) { ["count"]=> int(0) ["a"]=> int(0) ["b"]=> int(0) } Warning: {closure}(): Argument #3 ($data) must be passed by reference, value given in /in/e0Iu8 on line 21 Warning: {closure}(): Argument #3 ($data) must be passed by reference, value given in /in/e0Iu8 on line 21

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