PHP 遍历多维数组,获取指定的值

Array([result_num]=>1[result]=>Array([0]=>Array([location]=>Array([left]=>223[top]=>1... Array
(
[result_num] => 1
[result] => Array
(
[0] => Array
(
[location] => Array
(
[left] => 223
[top] => 193
[width] => 269
[height] => 250
)

[face_probability] => 1
[rotation_angle] => -3
[yaw] => 11.180804252625
[pitch] => -2.6816775798798
[roll] => -1.6329120397568
[landmark] => Array
(
[0] => Array
(
[x] => 280
[y] => 228
)

[1] => Array
(
[x] => 386
[y] => 222
)

[2] => Array
(
[x] => 323
[y] => 295
)

[3] => Array
(
[x] => 335
[y] => 348
)

)

[qualities] => Array
(
[occlusion] => Array
(
[left_eye] => 0
[right_eye] => 0
[nose] => 0
[mouth] => 0
[left_cheek] => 0
[right_cheek] => 0
[chin] => 0
)

[blur] => 0
[illumination] => 0
[completeness] => 0
[type] => Array
(
[human] => 0.93591904640198
[cartoon] => 0.064080975949764
)

)

)

)

[log_id] => 4178344165
)

我现在有一段这样数组,我需要获取里面每一个指定的值,方法最好是通用的,谢谢
展开
 我来答
折柳成萌
高粉答主

2018-03-30 · 繁杂信息太多,你要学会辨别
知道顶级答主
回答量:4.4万
采纳率:96%
帮助的人:6257万
展开全部
function getKey($arr,$key){
return is_array($arr[$key])?implode(',',$arr[$key]):$arr[$key];
}
$arr=Array ( 'name'=>'张三',
Array('phone' => Array('188','177','166')),
Array('sex' => '男') );
echo getKey($arr,'name');
echo getKey($arr,'phone');
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式