0

This is what I get when echo a variable called $SessionID:

string(76) "{"jsonrpc":"2.0","id":1,"result":"a0440004cf00a89c25377c9cdsf357f50644eec46fd96"}"

I wish to only echo the "result" part of this data, i.e, a0440004cf00a89c25377c9cdsf357f50644eec46fd96. How do I accomplish this?

I have already tried json_decode to no avail(it also echos the entire $SessionID as above without any change:

$decoded_data= json_decode($SessionID);
echo $decoded_data->result;

I have an inkling this might be because of the "string(76)" prepended to the response.

salmanxk
  • 315
  • 5
  • 19
  • [Seems to be working fine for me](http://sandbox.onlinephpfunctions.com/code/ce7d468aaaa34b457dd98f783c7f4c3964549226) – Andrei Aug 19 '20 at 21:56

1 Answers1

0

Will this work?

$decoded_data= json_decode($SessionID, true);
echo $decoded_data['result'];
MSC
  • 55
  • 7