如何从PHP代码中提取微信账单中的关键数据信息?
- 内容介绍
- 文章标签
- 相关推荐
本文共计528个文字,预计阅读时间需要3分钟。
最近需进行支付账户检查,确保第三方支付与数据库中账单一一对应,包含微信账户单的处理。微信账户接口返回结果为一个字符串类结果。程序需实现的功能便是从该字符串类结果中提取信息。
最近要做支付对账,即检查第三方支付与数据库中账单是否一一对应,涉及到微信对账单的处理,微信账单接口返回为一个字符串类似如下结果:
程序需要实现的功能就是从这个字符串从提取每一笔订单中的有效信息,参考代码如下:
function deal_wechat_return_result($reponse) { $result = array(); $reponse = str_replace(","," ",$reponse); $reponse = explode("`",$reponse); $total_order_count =( count($reponse) - 6 ) / 24; for($i = 0; $i< $total_order_count; $i++) { $base_index = 24 * $i; $result[$reponse[$base_index + 7]] = array( 'wechat_order_no' => $reponse[$base_index + 6], 'order_count' => $reponse[$base_index + 13], 'order_discount' => $reponse[$base_index + 23] ); } return $result; }
主要的思路是微信账单返回的结果格式是固定的,可以用 '`' 实现字符串的分割,然后每 24 个 字段为一个订单的描述信息,最后 6 个字段为账单的汇总信息。
本文共计528个文字,预计阅读时间需要3分钟。
最近需进行支付账户检查,确保第三方支付与数据库中账单一一对应,包含微信账户单的处理。微信账户接口返回结果为一个字符串类结果。程序需实现的功能便是从该字符串类结果中提取信息。
最近要做支付对账,即检查第三方支付与数据库中账单是否一一对应,涉及到微信对账单的处理,微信账单接口返回为一个字符串类似如下结果:
程序需要实现的功能就是从这个字符串从提取每一笔订单中的有效信息,参考代码如下:
function deal_wechat_return_result($reponse) { $result = array(); $reponse = str_replace(","," ",$reponse); $reponse = explode("`",$reponse); $total_order_count =( count($reponse) - 6 ) / 24; for($i = 0; $i< $total_order_count; $i++) { $base_index = 24 * $i; $result[$reponse[$base_index + 7]] = array( 'wechat_order_no' => $reponse[$base_index + 6], 'order_count' => $reponse[$base_index + 13], 'order_discount' => $reponse[$base_index + 23] ); } return $result; }
主要的思路是微信账单返回的结果格式是固定的,可以用 '`' 实现字符串的分割,然后每 24 个 字段为一个订单的描述信息,最后 6 个字段为账单的汇总信息。

