gpt4 book ai didi

php - 显示从 PHP 类中检索到的对象数组中的一个值

转载 作者:行者123 更新时间:2023-12-02 06:35:05 25 4
gpt4 key购买 nike

我有一个来自 PHP 类的对象,我将其加载到这样的数组中:

$result2 = json_decode($etsyService->request('/receipts/12121212'));

当我 print_r 数组 $result2 时,我得到:

stdClass Object
(
[count] => 1
[results] => Array
(
[0] => stdClass Object
(
[receipt_id] => 1212121212
[order_id] => 1111111
[seller_user_id] => 2525252
[buyer_user_id] => ABCD
[creation_tsz] => 0000000

我的问题是,如何单独echo这些字段之一?例如,只需回显 seller_user_id(即 2525252)。

最佳答案

结果是一个包含对象数组的对象。对对象属性使用 ->,对数组元素使用 [k]:

echo $result2->results[0]->seller_user_id

关于php - 显示从 PHP 类中检索到的对象数组中的一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21744886/

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