是否可以用某些星星替换文字?

时间:2019-11-27 11:44:12

标签: php

我有一个仅包含数字的16位文本。我有一个PHP变量,例如:$ example ['example'] 我希望此变量仅显示前6位和后4位,其他变量将被替换为星号。

已解决,并带有https://i.stack.imgur.com/C5ZPF.png

1 个答案:

答案 0 :(得分:0)

使用str_replace函数使操作变得简单

$example="1234567890123456";
$replace=str_replace(substr($example,6,6),str_repeat('*',6),$example);
echo "$replace";