Star out password for reminder


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.