3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [['user1' => 20], ['user2' => 30], 3 => ['user3' => 10]]; echo array_reduce( $array, fn($result, $row) => $result + current($row), 0 ); echo "\n---\n"; array_walk_recursive($array, function($v)use(&$sum){ $sum += $v; }); // visit each leafnode, increase the $sum tally echo $sum; echo "\n---\n"; $total = 0; // without this declaration, you will generate: "Notice: Undefined variable" foreach ($array as $subarray) { foreach ($subarray as $v) { $total += $v; } } echo $total;
Output for git.master, git.master_jit, rfc.property-hooks
60 --- 60 --- 60

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