Insert new array to php json -
i tried push new array value json
$var=array("code"=>"100"); $sql = select order orderid, pub ordercode cart while ($row = mysql_fetch_assoc ($sql) { $var[] = $row; } echo '{"status":'. json_encode($var).'}';
i want push string json array above
$string = array("total"=>"3000");
and script displays this:
{ "status":{ "code":"100", "0":{ "total":"3000" }, "1":{ "orderid":"16", "ordercode":"14290290685322" }, "2":{ "total":"3000" } } }
and want var total inside this:
**////////blablabla "1":{ "orderid":"16", "ordercode":"14290290685322", "total":"3000" } *///blablba
add $var[] = array("total"=>"3000");
before encode json
$var=array("code"=>"100"); $sql = select order orderid, pub ordercode cart while ($row = mysql_fetch_assoc ($sql) { $row['total'] = '3000' ; $var[] = $row; } echo '{"status":'. json_encode($var).'}';
Comments
Post a Comment