TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Special to plain characters (http://www.talkphp.com/advanced-php-programming/4438-special-plain-characters.html)

ReSpawN 05-26-2009 11:43 AM

Special to plain characters
 
Hey guys,

I've been working on a project for the last couple of months and now I bumped into a problem I've been putting off.

I've got the word 'Agapé', with the nice small comma on the e. For short, a special character. Now I need to change this to the word 'agape' without loosing anything.

strtolower works perfect, but I'm stuck the with the special character. How do I change it to it's 'parent', the letter e?

Salathe 05-26-2009 01:13 PM

Just use normal string functions to replace some characters (eg. àéîøü) with their equivalent ones (eg. aeiou).

ReSpawN 05-26-2009 02:20 PM

Well, simple enough. I'll give it a go. Thanks mate.

ReSpawN 05-27-2009 10:33 AM

I found and edited a function that does some of the work for me, either I wonder if I matched all the currently, most commonly used characters. Have a look;

PHP Code:

function tidyString($string){    
    
    
$string strtr($string"ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ""SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");    
    
$string preg_replace('#\b\%\d.(|\b)#u'''$string);    
    
$string preg_replace('#\b\%\d.(|\b)#u''+'$string);    
    
$string preg_replace('#\b\+\++(|\b)#u''+'$string);
    
    return 
$string;





All times are GMT. The time now is 09:48 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0