Массив перемещения и отображение в <li> <div> разметке

Я хочу пройти этот массив и отобразить его в маркированных div. Я знаю, что этот взгляд очень подозрительный, как и сам. Но я не могу пройти мимо вложенной проблемы foreach, особенно, когда дело доходит до deph потоков. Я получил ответ в предыдущем вопросе Traverse Array и Display In Bullet Points , но я не уверен, как изменить разметку в решении, которое было дано …. или если это возможно. Ниже представлен массив, и у меня есть ссылка на pastebin разметки, которую я бы хотел, но было бы здорово, если разметка может быть легко изменена в будущем, то есть разметки, отделенные от логики.

Array ( [1] => Array ( [id] => 1 [comment_title] => comment title [comment] => a [comment_date] => comment date [parent_id] => 0 [children] => Array ( [3] => Array ( [id] => 3 [comment_title] => comment title [comment] => this is another comment [comment_date] => comment date [parent_id] => 1 [depth] => 0 [child_count] => 0 [children] => ) [4] => Array ( [id] => 4 [comment_title] => comment title [comment] => this is a third comment [comment_date] => comment date [parent_id] => 1 [depth] => 0 [child_count] => 0 [children] => ) ) [depth] => 1 [child_count] => 2 ) [2] => Array ( [id] => 2 [comment_title] => comment title [comment] => this is yet another comment [comment_date] => comment date [parent_id] => 0 [children] => Array ( [5] => Array ( [id] => 5 [comment_title] => comment title [comment] => another comment [comment_date] => comment date [parent_id] => 2 [children] => Array ( [7] => Array ( [id] => 7 [comment_title] => comment title [comment] => Hey im a comment! [comment_date] => 1/1/1970 [parent_id] => 5 [children] => Array ( [8] => Array ( [id] => 8 [comment_title] => comment title [comment] => I disagree [comment_date] => 1/1/1970 [parent_id] => 7 [children] => Array ( [9] => Array ( [id] => 8 [comment_title] => comment title [comment] => My comment is... [comment_date] => 1/1/1970 [parent_id] => 8 [children] => Array ( [10] => Array ( [id] => 8 [comment_title] => comment title [comment] => Hey im a comment! [comment_date] => 1/1/1970 [parent_id] => 9 [depth] => 0 [child_count] => 0 [children] => ) ) [depth] => 1 [child_count] => 1 ) ) [depth] => 2 [child_count] => 1 ) ) [depth] => 3 [child_count] => 1 ) ) [depth] => 4 [child_count] => 1 ) [6] => Array ( [id] => 6 [comment_title] => comment title [comment] => This is the last comment [comment_date] => 1/1/1970 [parent_id] => 2 [depth] => 0 [child_count] => 0 [children] => ) ) [depth] => 5 [child_count] => 2 ) ) 

Вот разметка, которую я хочу использовать. http://pastebin.com/MBppxiC7

В коде, который я вам предоставил раньше, просто попробуйте добавить кусочки кода, и вы получите то, как он работает. Когда вы начнете понимать код, который я сделал, вы сможете расширить его и добавить дополнительные функции.

вы можете попробовать сделать рекурсивную функцию, которая проверяет наличие child_count, и если ее> 1, то функция снова пересечет дочерний ключ этого массива, чтобы получить детей. В принципе вы можете создать функцию и можете ее вызвать, когда это необходимо.