function mobileReplace($mobile,$start,$end,$str="*"){
$countStr = abs($end-$start);
$replaceStr = $str;
for($i=0;$i<$countStr;$i++){
$replaceStr.= $str;
}
$mobile = substr_replace($mobile, $replaceStr, $start-1, $countStr+1);
return $mobile;;
}
$mobile = '13188888888';
echo mobileReplace($mobile,4,7); //132****8888