-3

I want to hide a part of a string using my own function. For e.g: $string = "hello this is my password";. If my function is HashPartOfString($string), I want to put my string in this function and have an output like this: hel***************ord. How should I do that?

imGoat
  • 41
  • 3
  • Perhaps something like https://stackoverflow.com/questions/44200823/how-to-mask-parts-of-a-string-with-the-asterisk-character – Nigel Ren Apr 11 '21 at 14:55

1 Answers1

0

if you alltime wants to show 1st and last 3 letters and in between some * than you can do it by sub-string and string concat method

$str = "hello this is my password"; 
echo substr($str,0,3)."******".substr($str,(strlen($str))-3,3);
Mouri
  • 130
  • 1
  • 10
  • $str = "srfegkeruehkgu"; echo substr($str,0,3)."******".substr($str,(strlen($str))-3,3) – Mouri Apr 11 '21 at 15:07