Hi Guys,
I am really stuck with something and can’t get a way out.I am having a problem in creating a new array based on existing array.I have the following array and I want to match elements ‘id’ with ‘parent’ element. If the value is same then I want to create another array where the child elements will be under parent element.
[CODE]Array
(
[0] => Array
(
[id] => 66
[parent] => 26
)
[1] => Array
(
[id] => 47
[parent] => 26
)
[2] => Array
(
[id] => 48
[parent] => 66
)
I want it to be
[CODE]Array
(
[0] => Array
(
[id] => 66
[parent] => 26
)
[0] => Array
(
[id] => 48
[parent] => 66
)
[1] => Array
(
[id] => 47
[parent] => 26
)[/CODE]
I am stuck with the following code.I have got the values but I don’t know how to match with another element in a array.
[code=php] foreach($firstlevel_results as $k => $v)
{
echo $v[‘id’].”==”.$v[‘parent’].”==”.$v[‘grandparent’].”<br>”;
}
Please suggest if there is any possible way.Thanks in advance. ?