Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to iterate in multidimentional array in PHP?
- stdClass Object
- (
- [37] => Array
- (
- [term_id] => 37
- [name] => Files
- [parent] => 0
- [38] => Array
- (
- [term_id] => 38
- [name] => Downloads
- [parent] => 37
- )
- )
- [29] => Array
- (
- [term_id] => 29
- [name] => Articles
- [parent] => 0
- [36] => Array
- (
- [term_id] => 36
- [name] => General
- [parent] => 29
- )
- [35] => Array
- (
- [term_id] => 35
- [name] => WordPress
- [parent] => 29
- )
- [34] => Array
- (
- [term_id] => 34
- [name] => Php, Sql
- [parent] => 29
- )
- )
- [1] => Array
- (
- [term_id] => 1
- [name] => Uncategorized
- [parent] => 0
- )
- )
- Files
- Downloads
- Articles
- General
- WordPress
- Php, Sql
- Uncategorized
- $categories = get_array_content(); // Return the above data
- print_category_tree($categories);
- function print_category_tree(&$c)
- {
- foreach($c as $cat)
- {
- ?>
- <label>
- <input type="checkbox" value="<?php echo $cat['term_id']; ?>" /> <?php echo $cat['name']; ?>
- </label>
- <br />
- <?php
- foreach($cat as $categ)
- {
- if(is_array($categ))
- {
- print_category_tree($categ);
- }
- }
- }
- }
- print_category_tree($categ, $forum_id);
- function print_category_tree(&$c)
- function print_category_tree($c)
Advertisement
Add Comment
Please, Sign In to add comment