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