I am getting strings from a database and then using the strings to build a URL. My issue is, some of the strings will have characters like < > & { } * general specia
str_replace(' ','-',$string);
alphanumeric:
$output = preg_replace("/[^A-Za-z0-9]/","",$input);
if you want to keep the characters:
htmlspecialchars($string);