find all keys in 2D array



I have a 2D array. I want to find all sub array items, that are of
[type] => d.
then take the [id] of the found sub items, find any subitems that have
the same id with ":start" attached and take their [level] remove that
subitem and attach [level] to the type d item.

It's easier to explain with some example. I've got the followin array:

Array
(
[0] => Array
(
[id] => assortments
[type] => d
[level] => 1
)

[1] => Array
(
[id] => assortments:categories
[type] => d
[level] => 2
)

[2] => Array
(
[id] => assortments:start
[type] => f
[level] => 3
)
)

I want it to look like this:
Array
(
[0] => Array
(
[id] => assortments
[type] => d
[level] => 3
)

[1] => Array
(
[id] => assortments:categories
[type] => d
[level] => 2
)

)

Notice [3] is gone. It had the same id as [0] with a ':start' attached.
The [level] of that array sub item was then updated on item [0].

TIA..martin

.


Quantcast