开发者

How do I get the value of an object element inside an array?

开发者 https://www.devze.com 2023-03-09 06:44 出处:网络
I have the following array (print_r for formatting): $result =Array ( [link] => http://www.mysite.com/article/102758

I have the following array (print_r for formatting):

$result =  Array
(
    [link] => http://www.mysite.com/article/102758
    [type] => Article
    [title] => Sweetbay, PepsiCo Round the Bases
    [user] => <a href="/user/13208" title="View user profile.">pmalinowska</a> 
    [date] => 1306512291
    [node] => stdClass Object
        (
            [id] => dbcd60fee884/node/102758
            [nid] => 102758
            [uid] => 13208
            [title开发者_StackOverflow中文版] => Sweetbay, PepsiCo Round the Bases
            [type] => article
            [created] => 1306412903
            [changed] => 1306512291
            [comment_count] => 0
            [name] => pmalinowska
            [url] => http://www.mysite.com/article/102758
            [path] => node/102758
            [score] => 1.2324483
        )
)

How would I grab the value of the created property of the node element? I've tried the following:

$result->node->created;

$result['node']['created'];

$result->node['created']

None of them work.


Try

$result[ "node" ]->created

$result is an array while $result[ "node" ] is an object


Try this: $result['node']->created


$result['node'] is an object, so you must use object member access syntax.

So:

echo $result['node']->created;


I think $result['node']->created;

0

精彩评论

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