hi there,
I need a hand with recursion in php.
I've this array:
[Forum] => Array
(
[0] => Array
(
[id] => 12
[forum_category_id] => 2
[parent_id] => 0
[forum_post_id] => 0
[name] => PHP
[description] =>
[url] => php
[topics] => 0
[posts] => 0
[order] => 0
[topics_per_page] => 20
[ForumLastPost] =>
)
[1] => Array
(
[id] => 15
[forum_category_id] => 2
[parent_id] => 0
[forum_post_id] => 0
[name] => ASP.NET
[description] =>
[url] => asp_net
[topics] => 0
[posts] => 0
[order] => 0
[topics_per_page] => 20
[ForumLastPost] =>
)
[...]
[7] => Array
(
[id] => 21
[forum_category_id] => 2
[parent_id] => 0
[forum_post_id] => 0
[name] => Databases
[description] =>
[url] => databases
[topics] => 0
[posts] => 0
[order] => 0
[topics_per_page] => 20
[ForumLastPost] =>
)
[8] => Array
(
[id] => 22
[forum_category_id] => 2
[parent_id] => 21
[forum_post_id] => 0
[name] => MySQL
[description] =>
[url] => mysql
[topics] => 0
[posts] => 0
[order] => 0
[topics_per_page] => 20
[ForumLastPost] =>
)
[9] => Array
(
[id] => 23
[forum_category_id] => 2
[parent_id] => 21
[forum_post_id] => 0
[name] => SQLite
[description] =>
[url] => ms_sql
[topics] => 0
[posts] => 0
[order] => 1
[topics_per_page] => 20
[ForumLastPost] =>
)
[10] => Array
(
[id] => 24
[forum_category_id] => 2
[parent_id] => 23
[forum_post_id] => 0
[name] => 2000
[description] => SQL Server 2000
[url] => sql_server_2000
[topics] => 0
[posts] => 0
[order] => 1
[topics_per_page] => 20
[ForumLastPost] =>
)
)
I need to get a front page with every of those entries, but the ones that have no parent_id set or 0 need to be in <td> in a table, when the cycle encounters a child (parent_id > 0) need to break the cycle, make an h2 with this parent and then again make a table with their children, when this encounter another parent_id > 0 h2 and then table again, so I can have infinite n-tree recursion.
can somebody please help me out with a parser that generates html like this?
thanks