Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.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 多维数组foreach_Php_Arrays_Multidimensional Array - Fatal编程技术网

Php 多维数组foreach

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

我有一个多维数组,如下所示,我只想得到底部[image_meta]数组中[caption]的值

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'];