Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I have a multi array e.g

$a = array(
  'key' => (
    'sub_key' => 'val'
 ),
 'dif_key' => (
   'key' => (
     'sub_key' => 'val'
   )
 )
)

The real array I have is quite large and the keys are all at different positions.

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.

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.

E.g get all values from 'sub_key' regardless of position in array.

share|improve this question
1  
please add the code which you have tried. it ll he helpful to orrect you. – Niranjan N Raju 11 mins ago
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.