I am trying to replace anything in the string that is not a letter, number, or dash “-“.
How do I modify this line to include the dash?
$link = preg_replace('/[^a-z0-9]/', "", strtolower($_POST['link_name']));
Do I just insert it in there?
$link = preg_replace('/[^a-z0-9-]/', "", strtolower($_POST['link_name']));
You have to escape
-since it’s a special character for regexes: