Here's a multimensional array :
Array ( [0] => Array ( [id] => 5 [children] => Array ( [0] => Array ( [id] => 1 [children] => Array ( [0] => Array ( [id] => 2 ) ) ) ) ) [1] => Array ( [id] => 6 ) )
I'm looking for a PHP function which could remove a parent or grand-parent array from a given "id" value. For example, if id == 2, I'd like to remove the closest array with the key named "children", something like that :
Array ( [0] => Array ( [id] => 5 [children] => Array ( [0] => Array ( [id] => 1 ) ) ) [1] => Array ( [id] => 6 ) )
If id == 5, the new array would be :
Array ( [0] => Array ( [id] => 6 ) )
Or if id == 6, the new array would be :
Array ( [0] => Array ( [id] => 5 [children] => Array ( [0] => Array ( [id] => 1 [children] => Array ( [0] => Array ( [id] => 2 ) ) ) ) ) )
How do i do this with maybe a recursive function ? I would really appreciate some help ! Thanks ! :)