[size=24px][size=18px]如何获取json格式数据中某个指定字段的值?
如下json格式的数据:
{"returnCode":"0","resultCode":"0","sign":"19333CD7F9710A104DA5D815709697D2","outChannelNo":"2017120100401000000017","status":"02","mchId":"000000010000000002","channel":"wxPubQR","body":"收单支付","outTradeNo":"20171201150337579753","amount":0.01,"transTime":"20171201150337"}
我要直接获取body字段的值,如何不用json_decode的方法得到“”收单支付“”
如下json格式的数据:
{"returnCode":"0","resultCode":"0","sign":"19333CD7F9710A104DA5D815709697D2","outChannelNo":"2017120100401000000017","status":"02","mchId":"000000010000000002","channel":"wxPubQR","body":"收单支付","outTradeNo":"20171201150337579753","amount":0.01,"transTime":"20171201150337"}
我要直接获取body字段的值,如何不用json_decode的方法得到“”收单支付“”
解决方案 »
- 难倒300人的PHP问题(discuz)
- 100分求解:PHP 中怎么替换不固定的字符串 【在线等】
- PHP里取URL做为参数问题?
- 你们公司里都是什么样的人物出去和客户进行需求分析洽谈?
- 急球一个小功能的实现方法,万分感谢!!
- 在linux9+php4+apache+mysql下GD可以读取图片文件,但不能写入,请问原因。
- 请问php怎样连接interbase数据库呢?
- 有关网页自动跳转的命令??
- 为什么在windows98下,应用php不能对mysql数据库进行写操作!!!!
- 对象 转 数组 不会了
- CI框架里访问静态URL的问题
- 获取到数组,请问如何将数组医院为相同医院的科室合并到depart_list中
$re = '/"body":"([^"]+)"/';
$str = '{"returnCode":"0","resultCode":"0","sign":"19333CD7F9710A104DA5D815709697D2","outChannelNo":"2017120100401000000017","status":"02","mchId":"000000010000000002","channel":"wxPubQR","body":"收单支付","outTradeNo":"20171201150337579753","amount":0.01,"transTime":"20171201150337"}';
preg_match_all($re, $str, $matches);
print_r($matches[1]);
$str = '{"returnCode":"0","resultCode":"0","sign":"19333CD7F9710A104DA5D815709697D2","outChannelNo":"2017120100401000000017","status":"02","mchId":"000000010000000002","channel":"wxPubQR","body":"收单支付","outTradeNo":"20171201150337579753","amount":0.01,"transTime":"20171201150337"}';
preg_match_all($re, $str, $matches[1]);
print_r($matches);
切割
stripos
....方法很多不过有点『做』