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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -