PHP – Star Out the Password for Reminder

This simple function allows you to star out a password for simple reminder.

Code Example:

<?php
function star_out_password($password,$number_show){
	$star = '';
	if(is_numeric($number_show) && $number_show < strlen($password)){
    	$star = str_repeat('*',(strlen($password) - $number_show)) . substr($password,-$number_show,$number_show);
	}
	return $star;
}
   
$reminder = star_out_password('Dtua-23io#po9-0',3);
echo $reminder;  #returns ***********9-0
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail