<?php
$string ='{"type":"Text","totalprice":"0.05","totalgsm":"6","remaincredit":"63.6433","messages": [
{"status":"1","messageid":"157157","gsm":"9211111111111"},
{"status":"1","messageid":"157154","gsm":"9211111111112"},
{"status":"1","messageid":"157151","gsm":"9211111111113"},
{"status":"1","messageid":"157149","gsm":"9211111111114"},
{"status":"1","messageid":"157142","gsm":"9211111111115"},
{"status":"1","messageid":"157130","gsm":"9211111111116"}
]}';
?>
I want to get:
type = text
totalprice = 0.05
totalgsm = 6
remainingcredit = 63.6433
status=1 messageid=157157 gsm=9211111111111
status=1 messageid=157157 gsm=9211111111112
status=1 messageid=157157 gsm=9211111111113
status=1 messageid=157157 gsm=9211111111114
I want to insert in MYSQLDB in 2 queries:
First INSERT Query for type = text, totalprice = 0.05, totalgsm = 6, remainingcredit = 63.6433
Second INSERT Query for messages
array
Using foreach
to insert all given
status=1 messageid=157157 gsm=9211111111111
status=1 messageid=157157 gsm=9211111111112
status=1 messageid=157157 gsm=9211111111113
status=1 messageid=157157 gsm=9211111111114
Please Guide me how to decode this type of json response and how to parse to insert in DB?