How to mask parts of a string with the asterisk character

     

I want to get a phone number in this format


Your phone number ********8898 has been sent with a verification code..


PHP

  
"
answer1
  
  

Try this


$phone_number = '******' . substr( $phone_number - 4);  echo $phone_number;  
  
  
answer2
  
  

you can use substr :


$my_text = '12345678';
echo substr($my_text