3v4l.org

run code in 300+ PHP versions simultaneously
<?php $id = '9242'; $supergroup = array('9242' => 1, '9243' => 0, '9244' => 2, '9245' => 0); $supergroupnew = []; array_walk_recursive($supergroup, function($item, $key) use(&$id) { if ($key == $id) { $supergroupnew += [ $key => $item ]; } else { $supergroupnew += [ $key => "0" ]; } }); echo "<h1>Original Array:</h1>"; print_r($supergroup); echo "<h1>New Array:</h1>"; print_r($supergroupnew);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $supergroupnew in /in/J8Nmg on line 8 Fatal error: Uncaught TypeError: Unsupported operand types: null + array in /in/J8Nmg:8 Stack trace: #0 [internal function]: {closure}(1, 9242) #1 /in/J8Nmg(6): array_walk_recursive(Array, Object(Closure)) #2 {main} thrown in /in/J8Nmg on line 8
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:
66.79 ms | 401 KiB | 8 Q