Commit 677d3c66 authored by zhuwei's avatar zhuwei

优化

parent 7bb0366d
......@@ -96,46 +96,44 @@ function down_file($url, $dir, $filename=''){
return $filename;
}
/**
* 隐藏客户手机号中间几位
* zhuwei 2017年12月22日15:33:48
* @param $phone
* @return mixed|string
* 朱伟 2017年12月22日15:33:48
*/
function hide_customer_phone($phone)
{
//首先去除前后'|'
$phone=trim($phone, "|");
$phone = trim($phone, "|");
//然后判断里面是否有'|'
if(strpos($phone, "|") !== false){
if (strpos($phone, "|") !== false) {
$explode_phone = explode("|", $phone);
foreach ($explode_phone as $k => $v) {
if(checkMobileValidity($v)){
$explode_phone[$k]=substr_replace($v,'****',3,4);
if (checkMobileValidity($v)) {
$explode_phone[$k] = substr_replace($v, '****', 3, 4);
}
}
return implode("|", $explode_phone);
}else{
if(checkMobileValidity($phone)){
$phone=substr_replace($phone,'****',3,4);
} else {
if (checkMobileValidity($phone)) {
$phone = substr_replace($phone, '****', 3, 4);
}
return $phone;
}
}
////打印
//function prt($arr){
// echo "<pre/>";
// print_r($arr);
//}
/**^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
* 验证手机号是否正确
* zhuwei 2017-10-18 17:28:01
/**
*验证手机号是否正确
* @param $phone
* @return bool
* 朱伟 2017-10-18 17:28:01
*/
function checkMobileValidity($phone)
{
$mobilephone = trim($phone);
// $exp = "/^13[0-9]{1}[0-9]{8}$|15[012356789]{1}[0-9]{8}$|18[012356789]{1}[0-9]{8}$|14[57]{1}[0-9]$/";
$exp = "/^(1[0-9])\d{9}$/";
if (preg_match($exp, $mobilephone)) {
return true;
......@@ -144,35 +142,23 @@ function checkMobileValidity($phone)
}
}
/**
* 时间轴 '刚刚' '昨天' '前天'
* @param $time_inpute
* @return false|string
* 朱伟 2017-10-23 09:56:05
*/
function tranTime($time_inpute) {
$time2=strtotime($time_inpute);
function tranTime($time_inpute)
{
$time2 = strtotime($time_inpute);
$time = time() - $time2;
$rtime = date("H点i分s秒",$time2);
if ($time < 60) {
$str = '刚刚';
}
elseif ($time < 60 * 60) {
$min = floor($time/60);
$str = $min.'分钟前';
}
// elseif ($time < 60 * 60 * 24) {
// $h = floor($time/(60*60));
// $str = $h.'小时前 ';
// }
// elseif ($time < 60 * 60 * 24 * 3) {
// $d = floor($time/(60*60*24));
// if($d==1)
// $str = '昨天 '.$rtime;
// else
// $str = '前天 '.$rtime;
// }
else {
$str = date("Y-m-d",$time2);
} elseif ($time < 60 * 60) {
$min = floor($time / 60);
$str = $min . '分钟前';
} else {
$str = date("Y-m-d", $time2);
}
return $str;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment