3

我有以下带有数组的对象,并试图获取电子邮件的价值。如何才能做到这一点?

stdClass Object (
    [status] => stdClass Object ( 
        [info] => Unsubscribe List [code] => 200 
    ) 
    [data] => Array ( 
        [o1958147@rtrtr.com] => stdClass Object ( 
            [date] => 2013-01-28 08:09:19 
            [origin] => 
        ) 
        [phil.houston@granherne.com] => stdClass Object ( 
            [date] => 2013-01-28 08:35:59 
            [origin] => 
        ) 
    )    
) 

目前我可以使用以下 foreach 访问日期值。

foreach ($fnret->data as $msg)
{
    echo $msg->date;      // shows 2013-01-28 08:35:59
}
4

1 回答 1

7

这个应该工作:

foreach ($fnret->data as $email => $msg) {
    // echo $msg->date;      // shows 2013-01-28 08:35:59
    echo $email;
}
于 2013-01-29T14:55:32.030 回答