0

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];
}
1
  • var_dump($x); And use var_dump every time you have no idea what's in a variable Commented Jan 23, 2014 at 23:47

2 Answers 2

1

echo $caption_data['image_meta']['caption']

Sign up to request clarification or add additional context in comments.

Comments

0

You don't need a loop to get a single value. You can do:

$value = $array_containing_datastructure['image_meta']['caption'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.