Lambneck Posted December 29, 2012 Share Posted December 29, 2012 Theres this script floating around the web that replaces special characters with dashes but instead I would like specifically punctuation to NOT be replaced with anything but to just be removed... no white space, no dash. example: today's weather is hot! good:: todays-weather-is-hot bad: today-s-weather-is-hot- This script replaces does that bad example... how to make it do the good?: function secUrl($string){ $string = strtolower($string); $string = preg_replace('/[^a-zA-Z0-9]/i','-',$string); $string = preg_replace("/(-){2,}/",'$1',$string); return $string; } Quote Link to comment https://forums.phpfreaks.com/topic/272504-remove-punctuation-no-dashes/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.