// 加载文件
$spreadsheet = IOFactory::load($attachment);
// 读取内容
$sheetData = $spreadsheet->getSheet(0)->toArray(null, true, true, true);
// 循环检查数据
$allData = [];
$allError = [];
foreach ($sheetData as $key => $val) {
if ($key == 1) {
continue;
}
// 跳过空行
$val = array_map('trim', $val); // 去除首尾空格
if (empty(array_filter($val))) {
continue;
}
try {
$allData[] = $this->checkAndConvertItem($val);
} catch (\Exception $exception) {
$error = '第A' . $key . '行,此题需要检查,' . $exception->getMessage();
$allError[] = $error;
}
}通过array_filter过滤即可
通过http推送消息给socket,socket服务再向客户端推送<?php /* * Socket推送 * 请用守护进程方式启动php msgservice.php & (socket只...
md5/sha1+salt方式是目前各大cms常用的加密方式,虽然salt安全,但是各大md5网站也在研究这个方向,那么我们应该选择password_hash动态hash来助力,一种密码有多种hash结果.看代码模拟登陆.<?php //01.注册 $user ='zhang...
在一个正式项目中操作人员提交239个产品信息进行保存,但是系统却提示没有提交239个产品,于是开启错误信息,显示如下:Warning: Unknown: Input variables exceeded 1000. To incr...
项目中使用服务来执行webservice,由于对方系统api不稳定,经常导致服务崩溃,只能重启,一个月差不多要重启一次。初期的解决办法是捕获异常,然后continue掉。<?php try { $url = 'http...
(1).config.php 配置文件<?php /** * RabbitMQ_Config */ $config = [ 'host' => ...
主要原理是通过PHP创建多个子进程,在子进程中发送进程闹钟信号,然后再监听闹钟信号中继续发送闹钟信号。同时通过父进程设置非阻塞运行。代码如下:<?php /** * 订单任务 */ class Order { &n...