How can I loop through this array and get arrays with only similar values. In the example below, I would like to have an array that contains items 2, 3 and 4 because they all have category_parent => 4 in common.
I need to loop through that array so that I get the following result.
<ul>
<li>0</li>
<li>1
<ul>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</li>
<li>5</li>
</ul>
Array
(
[0] => stdClass Object
(
[term_id] => 3
[name] => Comercial
[slug] => comercial
[term_group] => 0
[term_taxonomy_id] => 3
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 1
[cat_ID] => 3
[category_count] => 1
[category_description] =>
[cat_name] => Comercial
[category_nicename] => comercial
[category_parent] => 0
)
[1] => stdClass Object
(
[term_id] => 4
[name] => Escolar
[slug] => escolar
[term_group] => 0
[term_taxonomy_id] => 4
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 0
[cat_ID] => 4
[category_count] => 0
[category_description] =>
[cat_name] => Escolar
[category_nicename] => escolar
[category_parent] => 0
)
[2] => stdClass Object
(
[term_id] => 5
[name] => Kinder
[slug] => kinder
[term_group] => 0
[term_taxonomy_id] => 5
[taxonomy] => category
[description] =>
[parent] => 4
[count] => 1
[cat_ID] => 5
[category_count] => 1
[category_description] =>
[cat_name] => Kinder
[category_nicename] => kinder
[category_parent] => 4
)
[3] => stdClass Object
(
[term_id] => 6
[name] => Primaria
[slug] => primaria
[term_group] => 0
[term_taxonomy_id] => 6
[taxonomy] => category
[description] =>
[parent] => 4
[count] => 1
[cat_ID] => 6
[category_count] => 1
[category_description] =>
[cat_name] => Primaria
[category_nicename] => primaria
[category_parent] => 4
)
[4] => stdClass Object
(
[term_id] => 7
[name] => Secundaria
[slug] => secundaria
[term_group] => 0
[term_taxonomy_id] => 7
[taxonomy] => category
[description] =>
[parent] => 4
[count] => 2
[cat_ID] => 7
[category_count] => 2
[category_description] =>
[cat_name] => Secundaria
[category_nicename] => secundaria
[category_parent] => 4
)
[5] => stdClass Object
(
[term_id] => 1
[name] => Uncategorized
[slug] => uncategorized
[term_group] => 0
[term_taxonomy_id] => 1
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 1
[cat_ID] => 1
[category_count] => 1
[category_description] =>
[cat_name] => Uncategorized
[category_nicename] => uncategorized
[category_parent] => 0
)
)
category_parent==4
. – Jack Maney Feb 9 '12 at 23:57<ul><li>2</li><li>3</li><li>4</li></ul>
– leonel Feb 10 '12 at 0:08