Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从php数组中获取自定义值_Php_Arrays - Fatal编程技术网

从php数组中获取自定义值

从php数组中获取自定义值,php,arrays,Php,Arrays,我有一个大阵列: 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] =&g

我有一个大阵列:

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 ) ) ) )
如何仅返回所有属性名称及其值?

您可以尝试以下方法(未测试):

array_column($array[0]['group_desc']['attributes'],'attr_name'),也许吧,但很难读取格式不好的数组。另外,我更喜欢,
var\u export
而不是
print\u r
,但不管怎样。
array_column($array[0]['attributes'], 'value', 'attr_name');