How can I replace a string with stars except the first and the last letter but not a minus in case there is one. Here for better illustration what I try to get: From: url-name To u**-***e
This is what I have so far:
function get_starred($str) {
$len = strlen($str);
return substr($str, 0, 1).str_repeat('_', $len - 2).substr($str, $len - 1, 1);
}