【发布时间】:2023-02-06 20:54:44
【问题描述】:
这是我要循环进入事件索引并从中打印出所有上下文的数组我该怎么做
这是我要循环的数组代码
[1] => stdClass Object
(
[id] => RPDNLNYO6U
[active] =>
[events] => Array
(
[0] => stdClass Object
(
[id] => RPDNLNYO6U_1
[created_at] => 2023-02-06T10:55:42.501003Z
[visibility] => all
[text] => Hi
[author_id] => 170bdd03-a163-49e9-4295-11fae376ff0e
)
[1] => stdClass Object
(
[id] => RPDNLNYO6U_2
[created_at] => 2023-02-06T10:55:44.102000Z
[visibility] => all
[text] => I need help
[author_id] => 170bdd03-a163-49e9-4295-11fae376ff0e
)
[2] => stdClass Object
(
[id] => RPDNLNYO6U_3
[created_at] => 2023-02-06T11:06:11.002000Z
[visibility] => agents
[type] => system_message
[text] => Chat is idle due to 10 minutes of inactivity
[system_message_type] => routing.idle
[text_vars] => stdClass Object
(
[duration] => 10
)
)
[3] => stdClass Object
(
[id] => RPDNLNYO6U_4
[created_at] => 2023-02-06T11:11:14.002000Z
[visibility] => all
[type] => system_message
[text] => Chat archived due to 15 minutes of inactivity
[system_message_type] => routing.archived_inactive
[text_vars] => stdClass Object
(
[duration] => 15
)
)
)
)
【问题讨论】:
-
你可以学习基本的 foreach 和数组来开始这个。
-
你有什么具体的关于这个数组的问题?
-
是的,我想从事件数组中获取所有文本,这是我的代码,我使用 foreach($obj_thread as $ky => $val){ foreach($obj_thread as $ky=>$val){ echo $val->events [$i]->text.'<br>'; //回声“你好+”.$j; } 回声“<br>”; $i++; }
标签: php