I have a simple multidimensional array like this: `
$array= [
'A' => [
'B' => ['D', 'E', 'F'],
'C' => 'G',
],
];
I need to return all node values with their parents. So I need an output like:
P[A] = 0;
P[B] = A;
P[D] = B;
P[E] = B;
P[F] = B;
P[C] = A;
P[G] = C;
I've tried some functions like array_search(), array_walk_recursive and so on, but I couldn't apply these functions to my situation.
Thanks very much for any help!