我有我的課如何從URL中刪除所有特殊字符?
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;
}
,但我不能讓我在使用特殊字符,如ö
和ü
等它的工作,sombody能幫助我在這裏?我使用PHP 5.3。
爲什麼你需要準確刪除變音符號?如果只是讓它通過一個HTTP URL,你可以使用'urlencode'。 – zneak 2010-03-15 17:04:33