当前位置:网站首页>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 .
边栏推荐
- Find in laravel8_ in_ Usage of set and upsert
- ORACLE EBS接口开发-json格式数据快捷生成
- 矩阵的Jordan分解实例
- JSP intelligent community property management system
- ORACLE 11G SYSAUX表空间满处理及move和shrink区别
- CRP实施方法论
- 使用Matlab实现:弦截法、二分法、CG法,求零点、解方程
- Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
- ERNIE1.0 与 ERNIE2.0 论文解读
- MySQL组合索引加不加ID
猜你喜欢
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
软件开发模式之敏捷开发(scrum)
[paper introduction] r-drop: regulated dropout for neural networks
架构设计三原则
【Ranking】Pre-trained Language Model based Ranking in Baidu Search
Check log4j problems using stain analysis
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
Classloader and parental delegation mechanism
一份Slide两张表格带你快速了解目标检测
Ding Dong, here comes the redis om object mapping framework
随机推荐
Three principles of architecture design
Play online games with mame32k
软件开发模式之敏捷开发(scrum)
第一个快应用(quickapp)demo
Explanation of suffix of Oracle EBS standard table
Find in laravel8_ in_ Usage of set and upsert
Agile development of software development pattern (scrum)
一个中年程序员学习中国近代史的小结
SSM二手交易网站
Oracle apex 21.2 installation and one click deployment
ORACLE EBS DATAGUARD 搭建
DNS attack details
[introduction to information retrieval] Chapter 6 term weight and vector space model
使用Matlab实现:弦截法、二分法、CG法,求零点、解方程
ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
Optimization method: meaning of common mathematical symbols
Analysis of MapReduce and yarn principles
【信息检索导论】第七章搜索系统中的评分计算
Two table Association of pyspark in idea2020 (field names are the same)
ORACLE 11.2.0.3 不停机处理SYSAUX表空间一直增长问题