I am kinda struggling, not sure what is wrong.
I am trying to get values from the response I get from API.
$response = json_decode($call);
Output
object(stdClass)#1 (3)
{
["valid"]=> bool(false)
["api"]=> object(stdClass)#3 (3)
{
["query_methode"]=> string(14) "set_client"
["query_client"]=> NULL
["query_timer"]=> string(6) "0.000s"
}
["reponse"]=> object(stdClass)#4 (1)
{
["info"]=> array(1)
{
[0]=> string(32) "Success."
}
}
}
I am trying to get ["valid"] and ["response"] message which is a success in this case.
$response = $response->valid; //doesnt work
if($response == true)
echo "works";
Then I tried,
$response = json_decode($call, true);
$results = (array) $response;
$valid = $results['valid']; // doesnt work too
$response= $results['reponse']; // doesnt work too
Not sure what is wrong with the code, any help will be appreciated.
source https://stackoverflow.com/questions/68967213/get-value-from-json-decode
Comments
Post a Comment