Copy Code code as follows:
/**
* Serial Number generator
*/
function Snmaker ($pre = ' ") {
$date = Date (' Ymd ');
$rand = rand (1000000,9999999);
$time = Mb_substr (Time (), 5, 5, ' utf-8 ');
$serialNumber = $pre. $date. $time. $rand;
echo strlen ($serialNumber). ' <br/> ';
return $serialNumber;
}
Echo Snmaker ();
/**
* Replace part of a string with a specific character
* @param str or int $str strings to be processed
* @param what string the str or int $to will be replaced
* @param int $start Preserve the first few characters
* @param int $end reserved after several characters
*/
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 ();