Q:

How can i filter  Percent of text like pa*****d

I'm developing an app that i need to show an string to user that's filtered with * !
let me explain it more!
we have "Password" as string that user will see with 8 letter length!
so i should filter 80% of this word then show the result like this : "pa*****d"
how can i do it with PHP?

A:

Simple like this:
$string = "password";

$mask_string =  substr($string,0, 4) . str_repeat("*", strlen($string)-5) . substr($string, -1);

echo $mask_string;

----Edit-----
If you want to use percentage this could be like this:
$percent = 0.80; //80%
$string = "password";
$cut = round(strlen($string)*$percent);
$show = strlen($string)-$cut;

$mask_string =  substr($string,0, $show) . str_repeat("*", $cut-1) . substr($string, -1);

echo $mask_string;

