我想使用我自己的函数隐藏字符串的一部分。例如:$string = "hello this is my password";
。如果我的功能是HashPartOfString($字符串),我希望把我的字符串在这个功能有一个这样的输出:hel***************ord
。我该怎么做?
如果您一直想显示第一个和最后三个字母以及一些 * 之间的字母,那么您可以通过子字符串和字符串 concat 方法来完成
$str = "hello this is my password";
echo substr($str,0,3)."******".substr($str,(strlen($str))-3,3);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句