I am creating a small message board in PHP and I need to “simplify” the topic title to display it in the url of the topic.
Examples:
Ceci est un sujet d'exemple becomes ceci-est-un-sujet-d-exemple
J'ai été à la plage becomes j-ai-ete-a-la-plage
I dislike sp&cial character$ becomes i-dislike-spcial-character (if there is a better translation, i take it)
EDIT 1 : All strings must be UTF-8 encoded
EDIT 2 : I recently learned that the result of this type of operation is called “slug” or “friendly url”
Here’s what I’ve done. I think I’ve covered most of the “common” characters. Obviously, it’s going to be missing some however.