开发者

Problem getting data out of an array

I have an array like the following:

开发者_JAVA技巧Array (
    [feed] => Array (
        [0] => Array (
            [title] => Stackoverflow
            [permalink] => http://www.stackoverflow.com
        )
        [1] => Array (
            [title] => Yahoo
            [permalink] => http://www.yahoo.com
        )
    )
)

How can I get the title? I tried this:

$data['feed']['title']


Shouldn't it be this:

$data['feed'][0]['title'] 


You should use

foreach($data['feed'] as $val) {
 echo $val['title']
}

to get all titles


You are missing the numeric index:

Array ( 
    [feed] => Array ( 
        [0] => Array ( 
            [title] => Stackoverflow[permalink] => http://www.stackoverflow.com) 
        [1] => Array ( 
            [title] => Yahoo [permalink] => http://www.yahoo.com) )
     )
)

$data['feed'][0]['title']

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜