16) { $string .= self::create_randnum($length - 16); } return $string; } //将前缀和数字id串连起来 //$prefix,前缀,格式如“LWMPT00000000001” //$id,要拼接的整数 //$length 长度 public static function noToStr($prefix, $id, $length = 16) { $id = $id . ""; $idLength = strlen($id); return substr($prefix,0,$length-$idLength).$id; } //对姓名做匿名处理 public static function niming($name) { $length = mb_strlen($name, 'utf-8'); if($length == 0 || $length == 1) { return '***'; } else { $head = mb_substr($name,0,1,'utf-8'); $last = mb_substr($name,($length-1),1,'utf-8'); } if ($length == 2) { return $head . "***"; } else { return $head . "***" . $last; } } public static function _unserialize($string) { return unserialize(preg_replace('!s:(\d+):"(.*?)";!se', '"s:".strlen("$2").":\"$2\";"', $string)); } //用于支付的唯一的订单号,长度24位 public static function GetOutTradeNo() { $out_trade_no = "LWM" . strtoupper(uniqid()) . strtoupper(self::create_noncestr(8)); return $out_trade_no; } public static function formatMonth($num , $day=0) { $year = floor($num/12); $month = $num%12; $str = $year ? $year . '年' : ''; $str.= $month ? $month . '个月' : ''; $day > 0 && $str .= $day.'天'; return $str; } // 产生店铺的随机字符串 public static function getShopNo() { $str = date('Ymd') . self::create_randnum(8); return $str; } }