I have strings with special characters I want to convert. Usually I find all the special characters and their “web safe” counter parts manually and put them in arrays. Then I use preg_replace to replace each of the characters.
But I cannot help but thinking that there is an easier solution since it is error prune approach.
Here is an example of what I want:
Hans Günther -> hans-gunther
Jären höst -> jaeren-hoest
René Ågesen -> rene-aagesen
string urlencode ( string $str )
http://php.net/manual/en/function.urlencode.php
Actually here is a great post about converting text like your example above to nice url-safe strings (probably better for you than the above function):
http://cubiq.org/the-perfect-php-clean-url-generator
Here are examples of what it does:
If you want to convert something like ä to ae and etc you can use a script like this (sorry, don’t know about a better way of doing this):
You can obviously put it all together like this (only converting ü->ue etc, just add more to the first preg_replace):