PHP - retrieve first element of json string without converting to array -


i have json string, probing follows:

$playedon = $query -> data -> artist -> services_played_on 

i want first element of services_played_on, unsure how this.. if array i'd $query[data][artist][services_played_on][0], various reasons mess other code have. have ideas how can using -> notation?

-----edit-----

thanks answers, needed was:

$playedon = $query -> data -> artist -> services_played_on[0] 

(i can't submit answer yet, 'new' user)

just decode json first.

$jset = json_decode($json, true); echo $jset["data"]["artist"]["services_played_on"][0]; 

Comments

Popular posts from this blog

haskell - Using filter on an item in a list? -

c# - When does PreApplicationStartMethod actually get triggered to run? -

tomcat6 - Exception when stopping container for a with Spring + Quartz + Tomcat web application -