0

Using an API from a third party app, I use an API call:

print_r($response->response());

the result:

  (
        [0] => stdClass Object
            (
                [id] => 41
                [id_format] => 2014-{num}
                [id_value] => 530
                [client_id] => 37
                [date_billed] => 2014-08-13 20:12:44
                [date_due] => 2014-08-13 20:12:44
                [date_closed] => 
                [date_autodebit] => 
                [status] => active
                [subtotal] => 15.0000
                [total] => 15.0000
                [paid] => 0.0000
                [previous_due] => 0.0000
                [currency] => USD
                [note_public] => 
                [note_private] => 
                [id_code] => 2014-530
                [delivery_date_sent] => 2014-08-13 20:15:10
                [client_id_code] => 1522
                [client_first_name] => Nate
                [client_last_name] => TestAccount
                [client_company] => 
                [client_address1] => 
                [client_email] => [email protected]
                [due] => 15.0000
            )

    )

I am trying to access these elements to no avail. I have tried the following so far:

$test =  $response->response()[0]->id;
$test =  $response->response(0)->id;
$test =  $response->response()->[0]->id;
$test =  $response->response()->[0]id;

I cannot seem to figure out the syntax to set an element to a variable.

Please do not flame, I am trying my best and would appreciate an extra set of eyes to help my stupidity.

1 Answer 1

2

Try,

$data = $response->response(); 
echo $data[0]->id;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.