Reputation: 614
I have a multidimensional array as shown below that I am wanting to simply get the value of [caption] which is in the [image_meta] array at the bottom.
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] =>
)
)
I've tried this for each loop below but not working
echo '<pre>';
print_r($caption_data);
echo '</pre>';
foreach ($caption_data as $x=>$x_value){
echo $x[0][3];
}
Upvotes: 0
Views: 42
Reputation: 33908
You don't need a loop to get a single value. You can do:
$value = $array_containing_datastructure['image_meta']['caption'];
Upvotes: 0