Transliterate characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leszek Dubiel

    #1

    Transliterate characters

    In perl I was able to do:

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

    How does this oneliner look like in php?

    Leszek Dubiel

    PS. Already searched for help...and found no answer....
  • Ian.H

    #2
    Re: Transliterate characters

    On Fri, 20 Aug 2004 11:05:22 -0700, Leszek Dubiel wrote:
    [color=blue]
    > In perl I was able to do:
    >
    > $var =~ y/ĘÓĄŚŁŻŹĆŃęóąśłż źćń/EOASLZXCNeoaslz xcn/;
    >
    > How does this oneliner look like in php?
    >
    > Leszek Dubiel
    >
    > PS. Already searched for help...and found no answer....[/color]


    PHP >= 4.3.0
    $var = html_entity_dec ode($var, ENT_NOQUOTES);


    Example taken from:


    <http://uk.php.net/manual/en/function.html-entity-decode.php>


    Pre-4.3.0 solution on that page also.


    HTH =)



    Regards,

    Ian

    --
    Ian.H
    digiServ Network
    London, UK


    Comment

    • Chung Leong

      #3
      Re: Transliterate characters

      "Leszek Dubiel" <leszek@dubiel. pl> wrote in message
      news:72ebed91.0 408201005.32b13 a3d@posting.goo gle.com...[color=blue]
      > In perl I was able to do:
      >
      > $var =~[/color]
      y/ĘÓĄŚŁŻŹĆŃęó ąśł
      żźćń/EOASLZXCNeoaslz xcn/;[color=blue]
      >
      > How does this oneliner look like in php?
      >
      > Leszek Dubiel
      >
      > PS. Already searched for help...and found no answer....[/color]

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


      Comment

      Working...