I want to target "KeyIwanttotarget" which is present on outside as well as nested.
The original file is JSON which I decoded into php using json_decode(). I want to target the specific key on all levels(external as well as nested) and store the value into another array e.g. using foreach and array_push.
"sample": [
{
"KeyIwanttotarget": "link",
"abc": "123",
"xyz": "123",
"pqr": "123",
"sample": [
{
"KeyIwanttotarget": "group",
"abc": "123",
"xyz": "123"
},
{
"KeyIwanttotarget": "link",
"abc": "123",
"xyz": "123",
"pqr": "123",
"sample": [
{
"KeyIwanttotarget": "link",
"abc": "123",
"xyz": "123",
"pqr": "123",
}
]
}
]
}
];