How to remove all special characters from URL?
Posted
by NeoNmaN
on Stack Overflow
See other posts from Stack Overflow
or by NeoNmaN
Published on 2010-03-15T17:02:01Z
Indexed on
2010/03/15
17:09 UTC
Read the original article
Hit count: 253
php
|string-manipulation
Hello all.
I have my class
public function convert( $title )
{
$nameout = strtolower( $title );
$nameout = str_replace(' ', '-', $nameout );
$nameout = str_replace('.', '', $nameout);
$nameout = str_replace('æ', 'ae', $nameout);
$nameout = str_replace('ø', 'oe', $nameout);
$nameout = str_replace('å', 'aa', $nameout);
$nameout = str_replace('(', '', $nameout);
$nameout = str_replace(')', '', $nameout);
$nameout = preg_replace("[^a-z0-9-]", "", $nameout);
return $nameout;
}
BUt I can't get it to work when I use special characters like ö
and ü
and other, can sombody help me here? I use PHP 5.3.
© Stack Overflow or respective owner