3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array( 'id' => 1, 'parent_id' => 0, 'title' => 'Parent Page', 'children' => array( array( 'id' => 2, 'parent_id' => 1, 'title' => 'Sub Page', ), array( 'id' => 5, 'parent_id' => 1, 'title' => 'Sub Page 2', 'children' => array( array( 'id' => 7, 'parent_id' => 5, 'title' => 'Sub Page', ), array( 'id' => 8, 'parent_id' => 5, 'title' => 'Sub Page 2', ) ) ) ) ), array( 'id' => 4, 'parent_id' => 0, 'title' => 'Another Parent Page', ) ); function printAll($arr, $parent = []) { if (is_array($arr)) { foreach ($arr as $k => $v) { if (isset($v['id'])) { $parent[] = $v['id']; echo implode('.', $parent) . PHP_EOL; } if (isset($v['children'])) { printAll($v['children'], $parent); } array_pop($parent); } } } printAll($arr);
Output for git.master, git.master_jit, rfc.property-hooks
1 1.2 1.5 1.5.7 1.5.8 4

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