title: PHP multidimensional array get value by key
body: <p>I have a multi array e.g</p>
  
  <pre><code>$a = array(
    'key' =&gt; array(
      'sub_key' =&gt; 'val'
   ),
   'dif_key' =&gt; array(
     'key' =&gt; array(
       'sub_key' =&gt; 'val'
     )
   )
  );
  </code></pre>
  
  <p>The real array I have is quite large and the keys are all at different positions.</p>
  
  <p>I've started to write a bunch of nested foreach and if/isset but it's not quite working and feels a bit 'wrong'. I'm fairly familiar with PHP but a bit stuck with this one. </p>
  
  <p>Is there a built in function or a best practise way that I can access all values based on the key name regardless of where it is. </p>
  
  <p>E.g get all values from 'sub_key' regardless of position in array.</p>
  
  <p><strong>EDIT</strong>: I see now the problem is that my "sub_key" is an array and therefore not included in the results as per the first comment here <a href="http://php.net/manual/en/function.array-walk-recursive.php" rel="nofollow">http://php.net/manual/en/function.array-walk-recursive.php</a></p>