3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function create_tree($arr,$pid=0) { $ret = array(); foreach($arr as $k => $v) { if($v['pid'] == $pid) { $tmp = $arr[$k];unset($arr[$k]); $tmp['children'] = create_tree($arr,$v['id']); $ret[] = $tmp; } } return $ret; }
Output for 4.3.0 - 7.1.7