应用场景: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>