Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
显示从PHP上的类检索的对象数组中的单个值_Php_Arrays_Object_Echo - Fatal编程技术网

显示从PHP上的类检索的对象数组中的单个值

显示从PHP上的类检索的对象数组中的单个值,php,arrays,object,echo,Php,Arrays,Object,Echo,我有一个对象来自PHP上的一个类,我将其加载到如下数组中: $result2 = json_decode($etsyService->request('/receipts/12121212')); 当我打印数组$result2时,我得到: stdClass Object ( [count] => 1 [results] => Array ( [0] => stdClass Object

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

$result2 = json_decode($etsyService->request('/receipts/12121212'));
当我打印数组$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

我的问题是,我怎样才能
单独回显这些字段中的一个?例如,只需回显卖方用户id(即2525252)。

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

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

只需按照您在打印输出中看到的对象/关联数组的轨迹进行操作

echo $result2->results[0]->receipt_id
尝试:

使用
->
可以访问对象,然后使用
[]
可以访问阵列

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