Php 多维数组foreach
我有一个多维数组,如下所示,我只想得到底部[image_meta]数组中[caption]的值Php 多维数组foreach,php,arrays,multidimensional-array,Php,Arrays,Multidimensional Array,我有一个多维数组,如下所示,我只想得到底部[image_meta]数组中[caption]的值 Array ( [file] => 2014/01/dreamstimecomp_5449062.jpg [sizes] => Array ( [thumbnail] => Array ( [file] => dreamstimecomp_5449062-150x150.jpg
Array
(
[file] => 2014/01/dreamstimecomp_5449062.jpg
[sizes] => Array
(
[thumbnail] => Array
(
[file] => dreamstimecomp_5449062-150x150.jpg
)
[medium] => Array
(
[file] => dreamstimecomp_5449062-300x224.jpg
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
)
)
我在下面的每个循环中都尝试过,但都不起作用
echo '<pre>';
print_r($caption_data);
echo '</pre>';
foreach ($caption_data as $x=>$x_value){
echo $x[0][3];
}
echo';
打印(标题数据);
回声';
foreach($x=>x$U值){
echo$x[0][3];
}
echo$caption\u data['image\u meta']['caption']
获取单个值不需要循环。你可以做:
var_dump($x)每次不知道变量中有什么时,使用var\u dump
$value = $array_containing_datastructure['image_meta']['caption'];