当前位置:网站首页>Determine whether the version number is continuous in PHP
Determine whether the version number is continuous in PHP
2022-07-02 07:27:00 【Snow wind in the night sky】
Preface
Doing it excel Data import into database tables requires validation excel Is the version number in the column of version number in continuous .
Version number format :1,1.1,1.2,1.2.1,2,2.1,2.2,2.2.1( correct )
Version number format :1,1.1,1.1,1.2.1,2,2.1,2.2,2.2.1( error )
Version number format :1,1.2,1.1,1.2.1,2,2.2,2.1,2.1.1( error )
I need to use php String functions in ,strpos,strrpos,substr.
/** * Judge whether the number is continuous , Number format :1,1.1,1.2,1.2.1,2,2.1,2.2,2.2.1 * @param $data * @param string $mark * @return void */
function judge_code_continuity($data, $errData = [], $mark = '.')
{
foreach ($data as $key => $val) {
if (!empty($val)) {
// Determine whether there are duplicate numbers
if (in_array($val, array_slice($data, 0, $key))) {
$errData[] = " Number " . $key . " Repetition exists , Please check and upload again ";
break;
}
if ($key == 0) {
} else if (!strpos($val, $mark)) {
if (!in_array($val - 1, array_slice($data, 0, $key))) {
$errData[] = $val . " There is a sequence error in the number , Please check and upload again ";
break;
}
} else {
$position = strrpos($val, $mark, 0);
$temp = substr($val, $position + 1, strlen($val) - $position) - 1;
$profit = substr($val, 0, $position);
$pointPosition = strrpos($profit, $mark, 0);
$pointBefore = substr($profit, 0, $pointPosition);
$pointAfter = substr($profit, -1, $pointPosition);
if ($temp == 0) {
if (!in_array(substr($val, 0, $position), array_slice($data, 0, $key))) {
$errData[] = $val . " There is a sequence error in the number , Please check and upload again ";
break;
}
} else {
if (!in_array(substr($val, 0, $position) . "." . ($temp), array_slice($data, 0, $key))) {
$errData[] = $val . " There is a sequence error in the number , Please check and upload again ";
break;
}
}
if ($pointBefore && in_array($pointBefore . "." . ($pointAfter + 1), array_slice($data, 0, $key))) {
$errData[] = $val . " There is a sequence error in the number , Please check and upload again ";
}
}
} else {
continue;
}
}
return $errData;
}
Here, a series of incorrect version numbers will be returned with error messages .
边栏推荐
- 【Torch】最简洁logging使用指南
- 叮咚,Redis OM对象映射框架来了
- Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi
- SSM supermarket order management system
- Sparksql data skew
- Using MATLAB to realize: Jacobi, Gauss Seidel iteration
- 华为机试题
- CONDA creates, replicates, and shares virtual environments
- [introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table
- oracle EBS标准表的后缀解释说明
猜你喜欢
Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
如何高效开发一款微信小程序
点云数据理解(PointNet实现第3步)
Analysis of MapReduce and yarn principles
【论文介绍】R-Drop: Regularized Dropout for Neural Networks
DNS攻击详解
Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix
[medical] participants to medical ontologies: Content Selection for Clinical Abstract Summarization
SSM实验室设备管理
Classloader and parental delegation mechanism
随机推荐
MapReduce与YARN原理解析
[torch] the most concise logging User Guide
Conda 创建,复制,分享虚拟环境
Oracle apex 21.2 installation and one click deployment
架构设计三原则
优化方法:常用数学符号的含义
Oracle rman自动恢复脚本(生产数据向测试迁移)
Implementation of purchase, sales and inventory system with ssm+mysql
【Ranking】Pre-trained Language Model based Ranking in Baidu Search
Oracle EBS DataGuard setup
allennlp 中的TypeError: Object of type Tensor is not JSON serializable错误
CSRF attack
JSP智能小区物业管理系统
Play online games with mame32k
Optimization method: meaning of common mathematical symbols
CONDA creates, replicates, and shares virtual environments
ORACLE EBS 和 APEX 集成登录及原理分析
中年人的认知科普
【论文介绍】R-Drop: Regularized Dropout for Neural Networks
Use matlab to realize: chord cut method, dichotomy, CG method, find zero point and solve equation