PHP reading through json -


we have created json follows

{"deliveries":[{"cn":"1498","airlinetype":" airbus a330-200 ","registration":" g-vygk ","airline":"thomas cook airlines","date":" 29. apr 2015 "}]}  

we trying loop through each delivery extracting data insert database. ran data through json validator , says ok. need use json_encode convert having problems trying access each of elements. best approach this?

thanks in advance rich

you want decode json string have posted.

a quick way since know name of each json branch following

$json = '{"deliveries":[{"cn":"1498","airlinetype":" airbus a330-200 ","registration":" g-vygk ","airline":"thomas cook airlines","date":" 29. apr 2015 "}]}'; $out = json_decode($json,true); foreach($out["deliveries"] $deliveries) { echo $deliveries["cn"]; echo $deliveries["airlinetype"]; echo $deliveries["registration"]; echo $deliveries["airline"]; echo $deliveries["date"]; } 

check out: http://sandbox.onlinephpfunctions.com/code/cfd8cdeb7f83536db4b4df74778243306c1c2d8c


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -