I am making a swedish website, and swedish letters are å, ä, and ö.
I need to make a string entered by a user to become url-safe with PHP.
Basically, need to
If you're just interested in making things URL safe, then you want urlencode.
Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type. This differs from the » RFC 1738 encoding (see rawurlencode()) in that for historical reasons, spaces are encoded as plus (+) signs.
If you really want to strip all non A-Z, a-z, 1-9 (what's wrong with 0, by the way?), then you want:
$mynewstring = preg_replace('/[^A-Za-z1-9]/', '', $str);