3v4l.org

run code in 500+ PHP versions simultaneously
<?php $comments = [ [1, 1, 'Comment 1'], [2, 1, 'Comment 2'], [3, 2, 'Comment 3'], [4, 1, 'Comment 4'], [5, 2, 'Comment 5'], [6, 3, 'Comment 6'], [7, 7, 'Comment 7'], ]; $map = []; foreach($comments as $c) { $id = $c[0] === $c[1] ? 0 : $c[1]; $map[$id][] = $c; } function print_comments($arr, $depth) { global $map; foreach($arr as $c) { echo str_repeat("--", $depth) . "{$c[2]}\n"; print_comments($map[$c[0]] ?? [], $depth+1); } } print_comments($map[0], 0);
Output for rfc.property-hooks, git.master, git.master_jit
Comment 1 --Comment 2 ----Comment 3 ------Comment 6 ----Comment 5 --Comment 4 Comment 7

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.16 ms | 1139 KiB | 4 Q