一定數目的字符我有哪裏我試圖掩蓋用戶的電子郵件的一部分與***PHP替換字符串
$user_email = [email protected]
$unmasked_user_email_array = explode('@', $user_email);
$unmasked_user_email_string = $unmasked_user_email[0];
$unmasked_user_email_string_length = strlen($unmasked_user_email_string);
if ($unmasked_user_email_string_length > 4) {
replace the last three characters of $unmasked_user_email_string with ***
}
else if ($unmasked_user_email_string_length < 5) {
replace the last two characters of $unmasked_user_email_string with **
}
else if ($unmasked_user_email_string_length < 4) {
replace the last one character of $unmasked_user_email_string with *
}
我的問題是,我應該用什麼方法或功能的當前代碼能夠完成我想要做的事情嗎?
感謝
故障:$ unmasked_user_email_string = $ unmasked_user_email [0] ;應該是$ unmasked_user_email_string = $ unmasked_user_email_array [0]; – 2014-10-07 07:16:58
謝謝,我糾正了在我的生產代碼:) – user2028856 2014-10-07 07:20:46