Transliterate characters

This is a discussion on Transliterate characters within the PHP Language forums, part of the PHP Programming Forums category; In perl I was able to do: $var =~ y/ĘÓĄŚŁŻŹĆŃęóąś&#...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-20-2004
Leszek Dubiel
 
Posts: n/a
Default Transliterate characters

In perl I was able to do:

$var =~ y/ĘÓĄŚŁŻŹĆŃęóąśłżźćń/EOASLZXCNeoaslzxcn/;

How does this oneliner look like in php?

Leszek Dubiel

PS. Already searched for help...and found no answer....
Reply With Quote
  #2 (permalink)  
Old 08-21-2004
Chung Leong
 
Posts: n/a
Default Re: Transliterate characters

"Leszek Dubiel" <leszek@dubiel.pl> wrote in message
news:72ebed91.0408201005.32b13a3d@posting.google.c om...
> In perl I was able to do:
>
> $var =~

y/ĘÓĄŚŁŻŹĆŃęóąśł
żźćń/EOASLZXCNeoaslzxcn/;
>
> How does this oneliner look like in php?
>
> Leszek Dubiel
>
> PS. Already searched for help...and found no answer....


The strtr() function is the PHP equivalent. The syntax is more verbose but
clearer.

$trans_tbl = array(
'&#280' => 'E',
'Ó' => 'O',
'&#260' => 'A',
....
);
$s = strtr($s, $trans_tbl);


Reply With Quote
Reply
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

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




All times are GMT +1. The time now is 09:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0