Return to Snippet

Revision: 63630
at May 23, 2013 08:15 by tylerpenney


Updated Code
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;
}

/*  TRY IT OUT */

$reminder = star_out_password('m$ypaSs423',4); // returns *******s423

Revision: 63629
at May 23, 2013 08:12 by tylerpenney


Initial Code
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;
}

Initial URL

                                

Initial Description
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

Initial Title
Star out password for reminder

Initial Tags

                                

Initial Language
PHP