Jump to content


Photo

Howto Filter symbols like ëíñçíàéö etc.


  • Please log in to reply
7 replies to this topic

#1 timmy01

timmy01
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 September 2006 - 02:23 PM

Hi guys,

what is the best and fastest / easiest way
to filter symbols like ëíñçíàéö etc.???

cheerz
Tim


#2 Nicklas

Nicklas
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • Locationwww.nswardh.com

Posted 06 September 2006 - 03:54 PM

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:

<?php
$string = 'bla bla bla ëíñçíàéö bla bla ñç...';

$chars = array('ë', 'í', 'ñ', 'ç', 'í', 'à', 'é', 'ö');
echo str_ireplace($chars, '', $string);
?>


#3 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 06 September 2006 - 04:07 PM

Why are you filtering these? You can remove non-ASCII characters via:

<pre>
<?php
	$string = 'to filter symbols like ëíñçíàéö etc.';
	echo preg_replace('/[^\x0-\x7f]/', '', $string);
?>
</pre>

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#4 timmy01

timmy01
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 07 September 2006 - 10:44 AM

no i mean replace them with like this:

ë=>e
í=>i
ñ=>n
ç=c
í=>i
à=>a
é=>e
ö=>o


...




#5 Nicklas

Nicklas
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • Locationwww.nswardh.com

Posted 07 September 2006 - 01:27 PM

<?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);

?>


#6 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 07 September 2006 - 02:15 PM

Have a look at this post.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#7 kevins

kevins
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 September 2006 - 08:50 AM

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);

?>

#8 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 05 October 2006 - 05:15 PM

I ran across this; "some code to convert latin diacritics to their traditional 7bit representation."
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users