2014-01-23 5 views
0

아래와 같이 [image_meta] 배열에있는 [caption]의 값을 얻고 싶습니다. 아래 그림과 같이 다차원 배열을 가지고 있습니다.다차원 배열 foreach

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]; 
} 
+0

'var_dump ($ x);'그리고 변수에 무엇이 들어 있는지 모를 때마다'var_dump'를 사용하십시오 – zerkms

답변

1

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

0

작동하지했습니다. 다음과 같이 할 수 있습니다 :

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