如何从中获取价值......?

时间:2022-04-30 09:58:29

Can someone explain me how to get data out of this...like if I just want subject, description..etc...

有人可以解释我如何从中获取数据...就像我只是想要主题,描述......等等...

stdClass Object
(
    [tickets] => Array
        (
            [0] => stdClass Object
                (
                    [url] => https://codemymobilecom.zendesk.com/api/v2/tickets/1.json
                    [id] => 1
                    [external_id] => 
                    [via] => stdClass Object
                        (
                            [channel] => sample_ticket
                            [source] => stdClass Object
                                (
                                    [from] => stdClass Object
                                        (
                                        )

                                    [to] => stdClass Object
                                        (
                                        )

                                    [rel] => 
                                )

                        )

                    [created_at] => 2015-04-22T08:30:29Z
                    [updated_at] => 2015-05-19T06:01:22Z
                    [type] => incident
                    [subject] => This is a sample ticket requested and submitted by you
                    [raw_subject] => This is a sample ticket requested and submitted by you
                    [description] => This is the first comment. Feel free to delete this sample ticket.
                    [priority] => high
                    [status] => closed
                    [recipient] => 
                    [requester_id] => 794599791
                    [submitter_id] => 794599791
                    [assignee_id] => 794599791
                    [organization_id] => 39742491
                    [group_id] => 24344491
                    [collaborator_ids] => Array
                        (
                        )

                    [forum_topic_id] => 
                    [problem_id] => 
                    [has_incidents] => 
                    [due_at] => 
                    [tags] => Array
                        (
                            [0] => sample
                            [1] => zendesk
                        )

                    [custom_fields] => Array
                        (
                        )

                    [satisfaction_rating] => 
                    [sharing_agreement_ids] => Array
                        (
                        )

                    [fields] => Array
                        (
                        )

                    [followup_ids] => Array
                        (
                        )

                    [brand_id] => 565681
                )

            [1] => stdClass Object
                (
                    [url] => https://codemymobilecom.zendesk.com/api/v2/tickets/10.json
                    [id] => 10 //multiple object like [0]...

Thanks...Any help would be great..

谢谢......任何帮助都会很棒..

3 个解决方案

#1


5  

When you need to access to array's key, use []. When you have object, use ->.

当您需要访问数组的密钥时,请使用[]。如果有对象,请使用 - >。

echo $obj->tickets[0]->subject; // returns first subject
echo $obj->tickets[0]->description; // returns first description

You can put it into foreach loop, of course to gain all subjects, etc.

你可以把它放到foreach循环中,当然要获得所有科目等。

#2


1  

It's STD object so use properties

这是STD对象所以使用属性

$obj->tickets[0]->subject
$obj->tickets[0]->description

You can obviously loop tickets

你可以显然循环门票

foreach($obj->tickets as $ticket)
{
   echo $ticket->subject;
   echo $ticket->description
}

#3


1  

this is an std object.to get subject and description follow this

这是一个std对象。获得主题和描述遵循此

$obj->tickets[0]->subject;
$obj->tickets[0]->description;

if you feel better in array just make it array using this code

如果您在数组中感觉更好,只需使用此代码创建数组

$array = get_object_vars($obj);

#1


5  

When you need to access to array's key, use []. When you have object, use ->.

当您需要访问数组的密钥时,请使用[]。如果有对象,请使用 - >。

echo $obj->tickets[0]->subject; // returns first subject
echo $obj->tickets[0]->description; // returns first description

You can put it into foreach loop, of course to gain all subjects, etc.

你可以把它放到foreach循环中,当然要获得所有科目等。

#2


1  

It's STD object so use properties

这是STD对象所以使用属性

$obj->tickets[0]->subject
$obj->tickets[0]->description

You can obviously loop tickets

你可以显然循环门票

foreach($obj->tickets as $ticket)
{
   echo $ticket->subject;
   echo $ticket->description
}

#3


1  

this is an std object.to get subject and description follow this

这是一个std对象。获得主题和描述遵循此

$obj->tickets[0]->subject;
$obj->tickets[0]->description;

if you feel better in array just make it array using this code

如果您在数组中感觉更好,只需使用此代码创建数组

$array = get_object_vars($obj);