gpt4 book ai didi

php - stdClass 对象和数组键值

转载 作者:可可西里 更新时间:2023-11-01 00:47:34 26 4
gpt4 key购买 nike

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

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
}

最佳答案

这个应该可以工作:

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

关于php - stdClass 对象和数组键值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14585726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com