Posted By

tylerpenney on 05/23/13


Tagged

password hide reminder


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


Star out password for reminder


 / Published in: PHP
 

Nice little function will star out a password for simple reminder - Original Password: password41! New: ******d41! Enter number of letters to show at end with $number_show

  1. function star_out_password($password,$number_show){
  2. $star = '';
  3. if(is_numeric($number_show) && $number_show < strlen($password){
  4. $star = str_repeat('*',(strlen($password) -$number_show)) . substr($password,-$number_show,$number_show);
  5. }
  6. return $star;
  7. }
  8.  
  9. /* TRY IT OUT */
  10.  
  11. $reminder = star_out_password('m$ypaSs423',4); // returns *******s423

Report this snippet  

You need to login to post a comment.