php中的3级数组来组织数据[关闭]

I want create a three-level array in php, with example data for developing purposes, I have this:

$data = array(
array(1 => array("A ROW GREENS", array(
    "A1" => array("http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg"),
    "A2" => array("http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg"),
    "A3" => array("http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg")
))),
array(2 => array("A ROW BLUE",array(
    "A1" => array("http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg"),
    "A2" => array("http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg"),
    "A3" => array("http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg")
))),

);

How you can see, this is the structure:

Element:[ID -> Title][IDSubitem1->URL, IDSubitem2->URL2...]
Element:[ID -> Title][IDSubitem1->URL, IDSubitem2->URL2...]
Element:[ID -> Title][IDSubitem1->URL, IDSubitem2->URL2...]

I need to print a <ul> with the Titles (using id for identifier them) and print other <ul> tags for show or hide the subitems or the selected parent.

<ul id="parent">
    <li id="1">A ROW GREENS</li>
    <li id="2">A ROW BLUE</li>
</ul>

<ul id="child1">
    <li id="child1-A1">http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg</li>
    <li id="child1-A2">http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg</li>
    <li id="child1-A3">http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg</li>
</ul>

<ul id="child2">
    <li id="child2-A1">http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg</li>
    <li id="child2-A2">http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg</li>
    <li id="child2-A3">http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg</li>
</ul>
查看全部
doumao9363
doumao9363
2016/10/05 19:30
  • php
  • arrays
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复