PHP实现单列内容快速查重与去重

应用场景:excel一列内容比如身份证号,可能有重复的,

则用此工具快速查询那些重复及显示去重后内容。

使用:粘贴一列数据,然后提交发送。

<?php
$tm = "单列查重去重(粘贴Excel中1列内容查重)!";

function tipx($str){
$str = str_replace(array("\r\n","\r","\n"),"|",Trim($str));
$strs= explode("|",$str);
$uni = array_count_values($strs);
  arsort($uni);
return $uni;
}

function tipy($str){
$str = str_replace(array("\r\n","\r","\n"),"|",Trim($str));
$strs= explode("|",$str);
$uni = array_unique($strs);
return join("\r\n",$uni);
}

function txtarea($nb,$ht="50vh") {
 return "<textarea style='display:inline;height:$ht;width:25vw;min-width:118px;'>$nb</textarea>";
}

if($_GET["x"] == "cha"){
$tips = isset($_POST['tips']) ? $_POST['tips'] : '';
$lisa = tipx($tips); $lisar=""; $licar=tipy($tips);
foreach($lisa as $key=>$val){
 if($val>1) $lisar .= "$key=>$val\r\n";
}
echo txtarea("查重:重复的\r\n".$lisar);
echo txtarea("去重:删重后\r\n".$licar);
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $tm;?></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<script type="text/javascript">
console.log("问题反馈电话:","15058593138");
console.log("问题反馈邮件:","admin@12391.net");
function $(objId){
return document.getElementById(objId);
}
function loadcha(xid) {
var xmlhttp;
var Stxt= "nums=aa";
Stxt+="&tips="+ encodeURIComponent($("tips").value);
//$("tips").innerHTML = "正在加载...";
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var btxt = xmlhttp.response;
if(btxt == "err01"){ $("tipx").innerHTML = "!"; return false;}
$('tipx').innerHTML = xmlhttp.response;
}
}
xmlhttp.open("POST", "?x=cha&tt="+Math.random(), true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(Stxt);
}
 
</script>
<style>
div,#tipx{display:block;width:99.7%;border:0;margin-top:5px;}
textarea{display:block;width:99.7%;border:1px solid #ccc;height:160px;}
table{margin:20px auto;border-left:1px solid #a2c6d3;border-top:3px solid #0180CF;font-size:12px;width:99.7%;}
table td{border-right:1px solid #a2c6d3;border-bottom:1px solid #a2c6d3;padding:2px;word-wrap:break-word;word-break:break-all;}
td{min-width:30px;max-width:490px;}
.tt{background-color: #f2f2f2;}
#submit{ height:35px;}
b{color:red;}
</style>
</head>
<body> 
<form class="form" id="form" method="POST" act="?act=cha" >
<p><?php echo $tm;?></p>
<textarea id="tips"></textarea>
 <input type="button" id="submit" value="提交发送" onclick="loadcha('xid')">
<div id="tipx"></div>
 </form>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YUJIANYUE

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值