I want to traverse this array and display, in bulleted divs. I know this look a lot suspicious, like do it yourself. But I cant get past the nested foreach problem, especially, when it comes to deph of the threads. I got an answer in a previous question Traverse Array and Display In Bullet Points, but i’m not sure how to change the markup in the solution that was given…. or if its possible. Below is the array, and i have a link to the pastebin of the markup i would like, but would be awesome if the markup can be changed easily in the future, ie markup views separated from logic.
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
)
)
Here is the markup i want to use. http://pastebin.com/MBppxiC7
In the code that I provided you before, just try adding pieces of code and you will get how it works. Once you begin understanding the code I made, you will be able to extend it and add your extra features.