//前端发送数据
var unPaid=JSON.stringify([{
"AMN_D" : "300. 0",
"AMN_T1" : "300. 0",
"FUELCODE" : "12",
"GCODE" : "测试",
"PRC" : "7.39",
"PayMode" : "0",
"Paystate" : "3"}])
//php接收数组
global $_GPC;
$orderlist=$_GPC['unPaid'];
$s1 = html_entity_decode($_GPC['unPaid']);
$s2 = stripslashes($s1);
$orderlist2=json_decode($s2, 1);
打印$orderlist:
[{"AMN_D":"300. 0","AMN_T1":"300. 0","ASN":"","FUELCODE":"12","GCODE":"测试","PRC":"7.39","PayMode":"0","Paystate":"3","SNO":"5","TIME":"20200213113657","TTC":"100","TTYPE":"6","VOL":"40.60","cardtype":"0"}]
打印$1:
[{"AMN_D":"300. 0","AMN_T1":"300. 0","ASN":"","FUELCODE":"12","GCODE":"测试","PRC":"7.39","PayMode":"0","Paystate":"3","SNO":"5","TIME":"20200213113657","TTC":"100","TTYPE":"6","VOL":"40.60","cardtype":"0"}]
打印$2:
[{"AMN_D":"300. 0","AMN_T1":"300. 0","ASN":"","FUELCODE":"12","GCODE":"测试","PRC":"7.39","PayMode":"0","Paystate":"3","SNO":"5","TIME":"20200213113657","TTC":"100","TTYPE":"6","VOL":"40.60","cardtype":"0"}]
打印orderlist2:
0={AMN_D=300. 0; AMN_T1=300. 0; ASN=; FUELCODE=12; GCODE=测试; PRC=7.39; PayMode=0; Paystate=3; SNO=5; TIME=20200213113657; TTC=100; TTYPE=6; VOL=40.60; cardtype=0; };
注:
- html_entity_decode() 函数把 HTML 实体转换为字符
- stripslashes()函数把字符转换为 HTML 实体。
- json_decode()函数 将json转换成对象/数组。当第二个参数为true返回 array ,默认是false返回object
- json_encode 将数组转化成json。
- urldecode()解码:还原 URL 编码字符串。
- urlencode():可将字符串以URL编码,用于编码处理。
来源:CSDN
作者:ckm紫韵
链接:https://blog.csdn.net/baidu_39212797/article/details/104481312