08-14-2009, 02:31 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
|
Special characters function
Hi, I have this function that takes a title with any random characters in it and generates a friendly url from it:
PHP Code:
function generateFriendlyURL($title)
{
// Switch none standard letters
$title1 = strtr($title,"ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ","SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
// Remove special chars
$allowed = "/[^a-z0-9\\040\\.\\-\\_]/i";
$title1 = preg_replace($allowed,"",$title1);
// Replace spaced with _
$title1 = preg_replace('/\s/', '_', $title1);
// Save
return $title1;
}
To test it I've then entered in this:
Code:
ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ
but the resulting friendly url is:
Code:
AAAAAAAAYAuAAAAAAAAAAASAAOAAZAAAAAAAAAAAsAAoAAYAAAAAAYAAAAAAAAAAAAAAAAuAAAAAAAA
Any ideas where I am going wrong?
Thanks,
Michael
|
|
|