I would like remove all keys [Name] but the main problem is the number in the list key ([List1],[List2] etc.). The numbers at key [List] may be more but for example I gave only two.
I would like to change this because it is an old json file and in the new one it doesn't have a key, like a converter
Is there a way to go across the entire array and remove all [Name] keys?
Array(
[Values] => 1
[List1] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
[Name] => Nm1
)
)
[1]=> Array(
[Properties] => Array(
[Id] => 1
[Name] => Nm1
)
)
)
[List1] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
[Name] => Nm1
)
)
)
)
[List2] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
[Name] => 0
)
)
)
)
)
[List2] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
[Name] => Nm1
)
)
)
[List1] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
[Name] => Nm1
)
)
)
)
)
)
My goal is:
Array(
[Values] => 1
[List1] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
)
)
[1]=> Array(
[Properties] => Array(
[Id] => 1
)
)
)
[List1] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
)
)
)
)
[List2] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
)
)
)
)
)
[List2] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
)
)
)
[List1] => Array(
[Product1] => Array(
[0] => Array(
[Properties] => Array(
[Id] => 1
)
)
)
)
)
)
I tried:
$ProductCount= count($array['List1']['Product1']);
for($i = 0;$i<$ProductCount;$i++){
unset($array['List1']['Product1'][$i][Properties][Name]);
}
But I also have a key[List2] and can be [List3] etc.