开发者

Problem getting data out of an array

开发者 https://www.devze.com 2023-03-02 18:25 出处:网络
I have an array like the following: 开发者_JAVA技巧Array ( [feed] => Array ( [0] => Array ( [title] => Stackoverflow

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

精彩评论

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