TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-14-2009, 02:31 PM   #1 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default 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
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 08-14-2009, 03:22 PM   #2 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

There isn't another function to generate characters randomly. Sorry if I didn't make it clear but the Title I pass into this function could be something like:

Facto Delafé y las Flores Azules

and needs the é replacing so the final output should be:

Facto_Delafe_y_las_Flores_Azules

but instead I get:

Facto_DelafA_y_las_Flores_Azules
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 08-17-2009, 03:00 PM   #3 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

Anyone with any ideas?
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
add special characters to DB? arale Absolute Beginners 0 07-08-2009 04:33 AM
Special to plain characters ReSpawN Advanced PHP Programming 3 05-27-2009 10:33 AM
Next class project? allworknoplay The Lounge 6 04-18-2009 08:33 PM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM


All times are GMT. The time now is 10:02 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design