3v4l.org

run code in 300+ PHP versions simultaneously
<?php $finalresult = array ( 101 => array( "username"=> "1st user", "children"=> array ( 104=> array ( "username"=> "4th user", "children"=> array() ), 105=> array ( "username"=> "5th user", "children"=> array() ), 108=> array ( "username"=> "new guy", "children"=> array() ) ) ), 102=> array ( "username"=> "2nd user", "children"=> array() ), 103=> array ( "username"=> "3rd user", "children"=> array() ) ); function count_children($tree) { $count = 0; foreach ($tree as $child) { $count++; if (is_array($child['children'])) { $count += count_children($child['children']); } } return $count; } echo count_children($finalresult);
Output for git.master, git.master_jit, rfc.property-hooks
6

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:
138.99 ms | 405 KiB | 5 Q