2009-02-03 12 views
0

이 배열에서 [주석] [title]을 차례로 출력하려면 어떻게해야합니까? $foo 배열입니다PHP - 배열의 특정 내용 출력

Array 
( 
    [User] => Array 
     (
      [id] => 121 
      [name] => Gwoo the Kungwoo 
      [created] => 2007-05-01 10:31:01 
     ) 
    [Comment] => Array 
     (
      [0] => Array 
       (
        [id] => 123 
        [user_id] => 121 
        [title] => On Gwoo the Kungwoo 
        [body] => The Kungwooness is not so Gwooish 
        [created] => 2006-05-01 10:31:01 
       ) 
      [1] => Array 
       (
        [id] => 123 
        [user_id] => 121 
        [title] => More on Gwoo 
        [body] => But what of the ‘Nut? 
        [created] => 2006-05-01 10:41:01 
       ) 
     ) 
) 
+0

cakephp perchance? 사물에 대한 변명 중 하나처럼 보입니다. – benlumley

답변

2

작동하지 않습니다, A) 템플릿

foreach ($foo['Comment'] as $comment) { 
    echo $comment['title']; 
} 

가, 디자이너처럼이 사용하려고 A]이어야한다 더 나은 :

foreach($foo['Comment'] as $comment): 
     echo $comment['title']; 
endforeach; 
4

는 수행

foreach ($foo['Comment'] as $comment) { 
    echo $comment['title']; 
}