Jump to content

Remove Punctuation No Dashes


Lambneck

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.