PHP DBC Category Tree Function
From Source Peek Wiki
This source code added in speculation and theory to CharBaseInfo.dbc and is irrelevant to any files, systems, or required algorithms presented in any World of Warcraft data.
$g_tree[] = array('id' => "your id", 'id_parent' => "your category parent", 'title' => " your title");
$ret_tree = array();
tree(0,0);
function tree($id_parent = 0, $indent = 0)
{
global $g_tree, $ret_tree;
$tt = array();
$x = 0;
$loop = 0;
foreach($g_tree as $n)
{
if( $n['id_parent'] == $id_parent)
{
$tt[$x++] = $loop;
}
$loop++;
}
if( $x != 0)
{
foreach($tt as $d)
{
$tmp = array();
foreach($g_tree[$d] as $key => $value)
{
$tmp[$key] = $value;
}
$tmp['indent'] = $indent;
$ret_tree[] = $tmp;
tree($tmp['id'], $indent+1);
}
}
else
{
return;
}
}
