1

I have this big array:

Array ( [0] => Array ( [group_id] => 87 
[group_name] => Étel jellemzők 
[group_slug] => etel_jellemzok 
[group_desc] => [attributes] => Array ( [0] => Array ( [attr_id] => 88 
[attr_name] => csípős [attr_slug] => csipos [attr_desc] => [value] => yes ) 
[1] => Array ( [attr_id] => 89 [attr_name] => gluténmentes [attr_slug] => glutenmentes [attr_desc] => [value] => yes ) 
[2] => Array ( [attr_id] => 90 [attr_name] => tejmentes [attr_slug] => tejmentes [attr_desc] => [value] => yes ) 
[3] => Array ( [attr_id] => 91 [attr_name] => új [attr_slug] => uj [attr_desc] => [value] => yes ) ) ) 
[1] => Array ( [group_id] => 92 [group_name] => Allergének [group_slug] => allergenek [group_desc] => [attributes] => Array ( [0] => Array ( [attr_id] => 93
[attr_name] => laktóz [attr_slug] => laktoz [attr_desc] => [value] => yes )
[1] => Array ( [attr_id] => 94 [attr_name] => glutén [attr_slug] => gluten [attr_desc] => [value] => yes )
[2] => Array ( [attr_id] => 95 [attr_name] => diófélék [attr_slug] => diofelek [attr_desc] => [value] => yes )
[3] => Array ( [attr_id] => 96 [attr_name] => szója [attr_slug] => szoja [attr_desc] => [value] => yes ) ) ) )

How can I return all attr_name and their values only?

1
  • 2
    array_column($array[0]['group_desc']['attributes'], 'attr_name');, maybe, but it's hard to read that poorly formatted array. Plus I would prefer, var_export to print_r but whatever. Commented Jan 11, 2018 at 0:29

1 Answer 1

1

You can try this (Un-tested):

array_column($array[0]['attributes'], 'value', 'attr_name');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.