从php对象中获取特定数据

时间:2017-04-02 08:00:52

标签: php object imap

使用https://github.com/ddeboer/imap,结合office365帐户,我需要检索发送电子邮件的电子邮件地址。

要检索,我使用:

$message->getFrom()

但结果是:

Ddeboer\Imap\Message\EmailAddress Object
(
    [mailbox:Ddeboer\Imap\Message\EmailAddress:private] => my
    [hostname:Ddeboer\Imap\Message\EmailAddress:private] => email.com
    [name:Ddeboer\Imap\Message\EmailAddress:private] => Full Name
    [address:Ddeboer\Imap\Message\EmailAddress:private] => my@email.com
)

如何仅检索此对象中的最后一部分(我需要my@email.com)

1 个答案:

答案 0 :(得分:2)

$message->getFrom()->getAddress()

Source