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; } Link to comment https://forums.phpfreaks.com/topic/272504-remove-punctuation-no-dashes/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.