function RemoveBadURLChars($str) { return preg_replace("/[^0-9a-zA-ZñÑ]+/", "-", $str);} $v = "Otoño, año, ññññññ";echo RemoveBadURLChars($v);