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
)
我现在有一段这样数组,我需要获取里面每一个指定的值,方法最好是通用的,谢谢 展开
(
[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
)
我现在有一段这样数组,我需要获取里面每一个指定的值,方法最好是通用的,谢谢 展开
1个回答
展开全部
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');
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');
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询