clean_string function
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
function clean_string($string) {
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
//echo clean('SKDKFJDFJKDJK!@#$%^&*()-adfkjkdfjkdfjDffd String');