3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['a' => 1, 'b' => 2], ['a' => 2, 'b' => 2] ]; $data = new stdClass(['count'=>0,'a'=>0,'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 (0) { } Warning: {closure}(): Argument #3 ($data) must be passed by reference, value given in /in/OHSDK on line 18 Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/OHSDK:13 Stack trace: #0 [internal function]: {closure}(Array, 0, Object(stdClass)) #1 /in/OHSDK(18): array_walk(Array, Object(Closure), Object(stdClass)) #2 {main} thrown in /in/OHSDK on line 13
Process exited with code 255.

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