I have a json string, which I am currently probing as follows:
$playedOn = $query -> data -> artist -> services_played_on
I now want to get the first element of this services_played_on, but am unsure how to do this.. If it were an array I'd just do $query[data][artist][services_played_on][0], but for various reasons this would mess up other code that I have. Anyone have any ideas how I can do this using the ->
notation?
-----EDIT-----
Thanks for your answers, but what I needed was:
$playedOn = $query -> data -> artist -> services_played_on[0]
(I can't submit this as an answer yet, as I am a 'new' user)
Just decode the JSON first.
$jset = json_decode($json, true);
echo $jset["data"]["artist"]["services_played_on"][0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With