0

prob an easy fix, but I'm stuck.

So print_r($data) =

stdClass Object ( [code] => 200000 [data] => stdClass Object ( [accountEquity] => 111 [unrealisedPNL] => 111 [marginBalance] => 111 [positionMargin] => 111 [orderMargin] => 0 [frozenFunds] => 0 [availableBalance] => 111 [currency] => xxx ) ) 

And echo $data->code outputs '20000'

But I can not get the other 'variables' to work. Ive tried:

$data->code->data->accountEquity $data[1]->accountEquity $data->code->data->accountEquity 

What is the right format to get those other values?

Thank you. gr Mike

2
  • Try restructuring your debug output, you'll see the solution pretty quickly then (I have edited your question). Otherwise, it would most likely help you to use a debugger for whatever IDE you are working with. Just Google "debug php with [your ide here]" Commented Jul 28, 2021 at 10:52
  • Welcome to Stackoverflow. Please read how to ask a good question and provide a minimal reproducible example preferably in a Stack snippet Commented Jul 28, 2021 at 16:01

2 Answers 2

1

The best way to get accountEquity is

$data->data->accountEquity 
Sign up to request clarification or add additional context in comments.

Comments

0

The right way to access accountEquity is:

$data->data->accountEquity 

But you could also cast the object to an array with:

$data = (array) $data; 

Then accountEquity is reached by:

$data['data']['accountEquity'] 

1 Comment

Glad i could help and welcome to SO. Please select my answer so the question is finished. Happy coding.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.