PHP Clean Function - Web Based Tool to Remove Special Characters and Replace Spaces with Hyphens

nction, web based tool, remove special characters, replace spaces with hyphens, multiple hyphens, input string.

function clean($string) {
   $string = str_replace(' ', '-', $string);
   $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);

   return preg_replace('/-+/', '-', $string);
}


echo clean($string);