// 加载文件
$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过滤即可
<?php function go($str) { echo'I\'m '.$str; } $goto='go'; $goto('gaojiufeng'...
原理:使用curl_init()创建多个请求实例,再使用curl_multi_init()批量执行创建的多个请求实例。文件1:curl.php<?php $threads=500;//并发请求次数 $url='http://blog.cn/index.php?';...
项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...
面试中PHP面试官会问调用一个不存在的方法,如何知道是哪个文件哪行调用的?假设方法是getWorkLoad()回答1:开启PHP错误输出,PHP会输出Fatal error: Call to undefined function getWorkLoad() in D:\wwwroot\thinkpa...
(1)swoole启动的主进程是master进程负责全局管理,然后master进程会再fork一个manager进程。(2)manager进程开始统一管理进程创建回收管理。(3)manager进程根据设置的worker_num和task_worker_num来创建work进程和task进程因此启动s...
在使用ftok生成ipc进程通信key尝试将第二个参数项目标识符传入字符串报错:PHP Warning: ftok(): Project identifier is invalid,查阅资料发现第二个字符串只能是1个字符串,长度为1....