PHP代码在线运行
<?php
date_default_timezone_set('Asia/Shanghai');
function change_star($str, $start, $end, $sign = '*') {
$start_str = mb_substr($str, 0, $start - 1);
$end_str = mb_substr($str, $end - 1);
$sign_str = '';
for($i = $start; $i < $end; $i++) {
$sign_str .= $sign;
}
return $start_str . $sign_str . $end_str;
}
$phone = '18888888888';
echo change_star($phone, 4, 8);