Representing data as a tree using PHP