3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = new stdClass(); $obj->id = ['a', 'b', 'a', 'c']; $obj->type = ['aaa', 'bbb', 'aaa', 'aaa']; $obj->num = [95, 100, 50, 11]; $sum = []; foreach($obj->id as $idx => $id) { if(!array_key_exists($id, $sum)) { $sum[$id] = []; } $sum[$obj->type[$id]] += $obj->num; } var_dump($sum);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "a" in /in/V7KoB on line 12 Warning: Undefined array key "" in /in/V7KoB on line 12 Fatal error: Uncaught TypeError: Unsupported operand types: null + array in /in/V7KoB:12 Stack trace: #0 {main} thrown in /in/V7KoB on line 12
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:
50.26 ms | 401 KiB | 8 Q