PHP код:
$test='WareZzz';
/*
Функция hideText()
@param (string) текст
@param (int) количество видимых символов
@return string
*/
function hideText($text, $first_last=1){
if(strlen($text) < $first_last*2) $first_last = 1;
return substr_replace($text, str_repeat('*',strlen($text)-($first_last*2)), $first_last, -$first_last);
}
echo hideText($test);
echo hideText($test, 2);
echo hideText($test, 3);
echo hideText($test, 4);
Цитата:
W*****z
Wa***zz
War*Zzz
W*****z
|