Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Tops
[parent_id] =>
)
[1] => stdClass Object
(
[id] => 2
[name] => Trousers
[parent_id] =>
)
[2] => stdClass Object
(
[id] => 3
[name] => Dresses
[parent_id] =>
)
[3] => stdClass Object
(
[id] => 4
[name] => Skirts
[parent_id] =>
)
[4] => stdClass Object
(
[id] => 5
[name] => Accessories
[parent_id] =>
)
[5] => stdClass Object
(
[id] => 6
[name] => Coats & Jackets
[parent_id] =>
)
)
Above is the parent categories i fetch from db.
And below are the sub categories
Array
(
[0] => stdClass Object
(
[id] => 8
[name] => Mini Tops
[parent_id] => 1
)
[1] => stdClass Object
(
[id] => 9
[name] => Long Tops
[parent_id] => 2
)
[2] => stdClass Object
(
[id] => 10
[name] => Cargo
[parent_id] => 2
)
[3] => stdClass Object
(
[id] => 11
[name] => Bermuda
[parent_id] => 2
)
[4] => stdClass Object
(
[id] => 12
[name] => Formal Dresses
[parent_id] => 3
)
[5] => stdClass Object
(
[id] => 13
[name] => Casual Dresses
[parent_id] => 3
)
[6] => stdClass Object
(
[id] => 14
[name] => Party Wear
[parent_id] => 3
)
[7] => stdClass Object
(
[id] => 15
[name] => Jewelry
[parent_id] => 4
)
[8] => stdClass Object
(
[id] => 16
[name] => Bracelets
[parent_id] => 4
)
[9] => stdClass Object
(
[id] => 17
[name] => Caps
[parent_id] => 4
)
)
below is how i am making my navitaion bar
<ul>
<li>
<a href="search.html">Tops</a>
<ul class="sub-menu">
<li><a href="search.html">Tshirts</a></li>
<li><a href="search.html">Jumpers</a></li>
<li><a href="search.html">Cardigans</a></li>
<li><a href="search.html">Knitwear</a></li>
</ul>
</li>
</ul>
As my logics are not so much good i actually trying to make navitaion with these two arrays in a way that the first array which are main links should be on top order where as all respective childs will appear in submenu of there respective parent_id example
Long Top, Cargo and Bermuda should be falling under Trousers Link.
I need guidance how can i achieve this .. I tried foreach loop but stucked in middle
Thanks alot