Remove Parent in PHP Multidimensional Array
arrays, multidimensional-array, php
Solution
Here’s the obvious:
foreach ($array as $key => $item) {
if ($item['text'] === 'a') {
unset($array[$key]);
}
}
Problem
What's the best way to remove the parent of a matched key in an Multidimensional Array? For example, let's assume we have the following array and I want to find "[text] = a" and then delete its parent array [0]... ``` (array) Array ( [0] => Array ( [text] => a [height] => 30 ) [1] => Array ( [text] => k [height] => 30 ) ) ```