加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP序列号生成函数和字符串替换函数代码

发布时间:2020-12-13 06:07:24 所属栏目:PHP教程 来源:网络整理
导读:div class="codetitle" a style="CURSOR: pointer" data="2282" class="copybut" id="copybut2282" onclick="doCopy('code2282')" 代码如下: div class="codebody" id="code2282" / 序列号生成器 / function snMaker($pre = '') { $date = date('Ymd'); $ran

<div class="codetitle"><a style="CURSOR: pointer" data="2282" class="copybut" id="copybut2282" onclick="doCopy('code2282')"> 代码如下:<div class="codebody" id="code2282">
/
序列号生成器
/
function snMaker($pre = '') {
$date = date('Ymd');
$rand = rand(1000000,9999999);
$time = mb_substr(time(),5,'utf-8');
$serialNumber = $pre.$date.$time.$rand;
// echo strlen($serialNumber).'
';
return $serialNumber;
}
echo snMaker();
/

将一个字符串的一部分替换成某一特定字符
@param str or int $str 需要处理的字符串
@param str or int $to 将替换成什么字符串
@param int $start 保留前几个字符
@param int $end 保留后几个字符
/
function hideString($str = 'hello',$to = '*',$start = 1,$end = 0) {
$lenth = strlen($str) - $start - $end;
$lenth = ($lenth < 0) ? 0 : $lenth;
$to = str_repeat($to,$lenth);
$str = substr_replace($str,$to,$start,$lenth);
return $str;
}
echo hideString();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读