php接收前端发送的数组

流过昼夜 提交于 2020-02-24 23:25:52
//前端发送数据
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; }; 

注:

  1. html_entity_decode() 函数把 HTML 实体转换为字符
  2. stripslashes()函数把字符转换为 HTML 实体。
  3. json_decode()函数 将json转换成对象/数组。当第二个参数为true返回 array ,默认是false返回object
  4. json_encode 将数组转化成json。
  5. urldecode()解码:还原 URL 编码字符串。
  6. urlencode():可将字符串以URL编码,用于编码处理。
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!