I want to echo a certain part of json in php. I don't know if the json data is valid or invalid.
I have tried the below code:
$get = get_content('domain');
$json = file_get_contents($get);
$decode = json_decode($json);
$final = $decode->count;
echo $final;
The json data which I get from an URL is:
{"15":{"xy":{"cost":6,"count":235}}}
I expect to see only the 235 part. This data keeps on changing. Sometimes the number 6 in the cost can vary as well.
EDIT: Fixed some code. EDIT1: Actually the data was already a string so just used echo substr($get, 30, 3); to achieve the results.