mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-27 16:11:22 +08:00
65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Website: https://mudew.com/
|
|
* Author: Lkeme
|
|
* License: The MIT License
|
|
* Email: Useri@live.cn
|
|
* Updated: 2021 ~ 2022
|
|
*/
|
|
|
|
namespace BiliHelper\Tool;
|
|
|
|
class Common
|
|
{
|
|
|
|
/**
|
|
* @use 获取十三位时间戳
|
|
* @return int
|
|
*/
|
|
public static function getMillisecond(): int
|
|
{
|
|
list($t1, $t2) = explode(' ', microtime());
|
|
// return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
|
|
return intval(sprintf('%u', (floatval($t1) + floatval($t2)) * 1000));
|
|
}
|
|
|
|
/**
|
|
* @use 替换字符串
|
|
* @param $str
|
|
* @param $start
|
|
* @param int $end
|
|
* @param string $dot
|
|
* @param string $charset
|
|
* @return string
|
|
*/
|
|
public static function replaceStar($str, $start, $end = 0, $dot = "*", $charset = "UTF-8"): string
|
|
{
|
|
$len = mb_strlen($str, $charset);
|
|
if ($start == 0 || $start > $len) {
|
|
$start = 1;
|
|
}
|
|
if ($end != 0 && $end > $len) {
|
|
$end = $len - 2;
|
|
}
|
|
$endStart = $len - $end;
|
|
$top = mb_substr($str, 0, $start, $charset);
|
|
$bottom = "";
|
|
if ($endStart > 0) {
|
|
$bottom = mb_substr($str, $endStart, $end, $charset);
|
|
}
|
|
$len = $len - mb_strlen($top, $charset);
|
|
$len = $len - mb_strlen($bottom, $charset);
|
|
$newStr = $top;
|
|
for ($i = 0; $i < $len; $i++) {
|
|
$newStr .= $dot;
|
|
}
|
|
$newStr .= $bottom;
|
|
return $newStr;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|