I am new to PHP, I am trying to learn it. Actually, I am not getting what is this format and how to get the result from it. below is my code after var_dump:
$data = some array();
var_dump($data);
/*
object(stdClass)#58 (3) {
["jsonrpc"]=> string(3) "2.0"
["id"]=> int(1)
["result"]=> string(42) "Success"
}
*/
Now I want the 'result' parameter only as a string. I am trying to do this way:
$reult = $data['result'];
but it is giving Illegal string offset 'result'
error.
echo $data->result;
You can use this to echo the object value
Or you can cast it as array
var_dump( (array) $data);
$data=(array) $data;
echo $data[result];
You can try this:
$res = decode($data, true);
$reult = $res['result'];
Your data is a PHP stdClass. In my opinion you should convert it to array. After that you can easily use it.