I have the following string Available:
$flatPath = '0/instances/0';
With this information I want to be able to unset the element from a multidimensional array like this:
$array = [['instances' => [1,2], ['instances' => [3,4]]
Therefor the Result should look like:
$array = [['instances' => [2], ['instances' => [3,4]]
Statically it would look like:
unset($array[0]['instances'][0]);
I want to be able to remove items in any given string path if available in the array.
Therefore the solution has to be able to remove any item from a multidimensional array, irrespective of the structure of the $array
, as long as the $flatPath
exists.
Thank you in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…