So lets say I have a password in the form of a string:
$password = "thisisaplaintextpassword"
How can I turn it into the following?
$password = "************************"
I would like to send users their account details via email, and don't want to send the entire thing.
Use str_repeat
$password = str_repeat("*", strlen($password));
function hidePassword($p) {
$fit = strlen($p);
return sprintf("%'*-${fit}s",false);
}
echo hidePassword($p);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With