源码:特别适用于微信支付中通知微信支付网关
function array2xml($arr, $level = 1) { $s = $level == 1 ? "<xml>" : ''; foreach ($arr as $tagname => $value) { //元素为数组或者不为数组的处理 if (!is_array($value)) { $s .= "<{$tagname}>" . (!is_numeric($value) ? '<![CDATA[' : '') . $value . (!is_numeric($value) ? ']]>' : '') . "</{$tagname}>"; } else { $s .= "<{$tagname}>" . array2xml($value, $level + 1) . "</{$tagname}>"; } } //过滤不合法的字符串 $s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s); return $level == 1 ? $s . "</xml>" : $s; } //微信支付通知后告诉微信网关,我收到了! $data=array( 'return_code'=>'SUCCESS', 'return_msg' =>'OK', ); $xmlstr=array2xml($data);
代码1:for循环批量插入100W数据<?php set_time_limit(0); $servername = "localhost"; $username = "root"; $password ...
(1).创建数据库test ,创建表shop(字段id,total),商品id是1,商品总数10 (2).PHP模拟购买,商品数量大于0才能购买<?php //连接数据库 $con=mysqli_connect("192.168.2.18...
项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...
array_merge是最常用的数组合并方法,+号同样也可以,但是却有很大不同。array_merge遇到相同字符串key,后面数组的key会覆盖前面数组的key,+号正好相反。$a = [ 'one' => 'A on...
php7新增的特性(1).强制限制只能返回一种类型<?php class task { } //must return an integer function add(): int { &nb...
【一】.基本用法首先看看官方对send方法的解释:Sets the return value of the yield expression and resumes the generato...