3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array( null => array(1, 2, 3, 4, 5), 2 => array(6, 7, 8, 9), 3 => array(10, 11), 10 => array(12), 12 => array(13) ); $nodes = array( 1 => array( "title" => 1, ), 2 => array( "title" => 2, ), 3 => array( "title" => 3, ), 4 => array( "title" => 4, ), 5 => array( "title" => 5, ), 6 => array( "title" => 6, ), 7 => array( "title" => 7, ), 8 => array( "title" => 8, ), 9 => array( "title" => 9, ), 10 => array( "title" => 10, ), 11 => array( "title" => 11, ), 12 => array( "title" => 12, ), 13 => array( "title" => 13, ), ); function f($node) { global $nodes, $a; if (!isset($nodes[$node]["children"])) { $nodes[$node]["children"] = array(); } if (isset($a[$node])) { foreach($a[$node] as $child) { array_push($nodes[$node]["children"], f($child)); } } return $nodes[$node]; } f(null); print_r($nodes[null]["children"]);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [title] => 1 [children] => Array ( ) ) [1] => Array ( [title] => 2 [children] => Array ( [0] => Array ( [title] => 6 [children] => Array ( ) ) [1] => Array ( [title] => 7 [children] => Array ( ) ) [2] => Array ( [title] => 8 [children] => Array ( ) ) [3] => Array ( [title] => 9 [children] => Array ( ) ) ) ) [2] => Array ( [title] => 3 [children] => Array ( [0] => Array ( [title] => 10 [children] => Array ( [0] => Array ( [title] => 12 [children] => Array ( [0] => Array ( [title] => 13 [children] => Array ( ) ) ) ) ) ) [1] => Array ( [title] => 11 [children] => Array ( ) ) ) ) [3] => Array ( [title] => 4 [children] => Array ( ) ) [4] => Array ( [title] => 5 [children] => Array ( ) ) )

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:
52.3 ms | 409 KiB | 8 Q