doujie1917 2013-04-13 16:43
浏览 9
已采纳

too long

I have a problem with a replacing characters, I do not know how to do that. We in Slovakia have characters with interpunctions.

How do I change (eg. á) for html code at input. If I have a string like Áno (translated yes), how do I change á to html code at the string.

I want make input where smiles like :-) will change to image. Or my interpunctioned characters to html code.

  • 写回答

1条回答 默认 最新

  • drtwqc3744 2013-04-13 16:49
    关注

    You can use strtr for such purposes. I do not know what problems you have to solve with smileys etc, so I'll give you an example for German umlauts (however not to HTML entities, but to standard ASCII characters):

    $string = strtr($string, array('ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue'));
    

    Of course you can also use HTML entities instead of ae etc, you just have to look them up.

    Edit

    Judging from your update (I want make input where smiles like :-) will change to image. Or my interpunctioned characters to html code.) I think you want to use both htmlentities and strtr.

    htmlentities will make sure that all non-ASCII characters are displayed correctly. Also have a look at UTF-8. With UTF-8, you will not have to translate your czech characters.

    And strtr will replace your smileys by the proper HTML code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题