timmy01 Posted September 5, 2006 Share Posted September 5, 2006 Hi guys,what is the best and fastest / easiest wayto filter symbols like ëíñçíàéö etc.???cheerzTim Quote Link to comment Share on other sites More sharing options...
Nicklas Posted September 6, 2006 Share Posted September 6, 2006 with "filter", you mean remove them?You could place all the letters you wanna remove in an array and then use str_ireplace() (if you use PHP 5) to delete them.ex:[color=blue]<?php$string = 'bla bla bla ëíñçíàéö bla bla ñç...';$chars = array('ë', 'í', 'ñ', 'ç', 'í', 'à', 'é', 'ö');echo str_ireplace($chars, '', $string);?>[/color] Quote Link to comment Share on other sites More sharing options...
effigy Posted September 6, 2006 Share Posted September 6, 2006 Why are you filtering these? You can remove non-ASCII characters via:[code]<pre><?php $string = 'to filter symbols like ëíñçíàéö etc.'; echo preg_replace('/[^\x0-\x7f]/', '', $string);?></pre>[/code] Quote Link to comment Share on other sites More sharing options...
timmy01 Posted September 7, 2006 Author Share Posted September 7, 2006 no i mean replace them with like this:ë=>eí=>iñ=>nç=cí=>ià=>aé=>eö=>o ... Quote Link to comment Share on other sites More sharing options...
Nicklas Posted September 7, 2006 Share Posted September 7, 2006 [code=php:0]<?php$string = 'bla bla bla ëíñçíàéö bla bla ñç...';$change = array('ë', 'í', 'ñ', 'ç', 'í', 'à', 'é', 'ö');$tothis = array('a', 'i', 'n', 'c', 'i', 'a', 'e', 'o');echo str_replace($change, $tothis, $string);?>[/code] Quote Link to comment Share on other sites More sharing options...
effigy Posted September 7, 2006 Share Posted September 7, 2006 Have a look at [url=http://www.phpfreaks.com/forums/index.php/topic,100331.msg395933.html#msg395933]this[/url] post. Quote Link to comment Share on other sites More sharing options...
kevins Posted September 25, 2006 Share Posted September 25, 2006 It does not work if $change contains non-ASCII chars like α - β - Ğ - ğ - İ - ı - Ş - ş<?php$string = 'bla bla bla ëíñçíàéö bla bla ñç...';$change = array("α", "β", "Ğ", "ğ" );$tothis = array('a', 'i', 'n', 'c', 'i', 'a', 'e', 'o');echo str_replace($change, $tothis, $string);?> Quote Link to comment Share on other sites More sharing options...
effigy Posted October 5, 2006 Share Posted October 5, 2006 I ran across [url=http://us2.php.net/manual/en/function.mb-convert-encoding.php#69412]this[/url]; "some code to convert latin diacritics to their traditional 7bit representation." Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.