【问题标题】:How to echo text right-to-left in php?如何在php中从右到左回显文本?
【发布时间】:2014-06-03 00:51:55
【问题描述】:

有没有办法在 php 中回显文本 rtl? 我正在使用 css 代码方向邮件保护:

.safemail{
    direction: rtl;
    unicode-bidi: bidi-override;
}

为此,我需要从右到左回显邮件

【问题讨论】:

    标签: php css


    【解决方案1】:

    试试strrevhttp://www.php.net/manual/en/function.strrev.php

    这是一个例子:

    <?php
    echo strrev("Hello world!"); // outputs "!dlrow olleH"
    ?>
    

    【讨论】:

      【解决方案2】:

      1 选项是在 php 中反转字符串,如其他人所述。但是对于大文本,在为许多人处理大量文本时,这对您的服务器来说可能很繁重。

      一个选项是使用以下 html 字符

      &#x202e; this text will be reversed as it is after the special char <br>
      &#x202d; this text won't be reversed anymore
      

      http://jsfiddle.net/sYafq/ --> 概念证明。

      第一个特殊字符将反转以下所有文本。

      第二个特殊将撤消以下文本的效果。请注意,当您不放置
      标签时,第二句将出现在第一句之前。

      如果你有 1 段文字要反转,你可以按如下方式使用它

      not reversed text
      <div>
          &#x202e; reversed text
      </div>
      not reversed text
      

      【讨论】:

      • @Yesian 这是一个更好的解决方案,因为它将处理负载推到客户端。
      【解决方案3】:

      您正在寻找字符串反转功能:http://www.php.net/manual/en/function.strrev.php

      <?php
      echo strrev("mail@domain.com");
      ?>
      

      【讨论】:

        猜你喜欢
        • 2018-01-05
        • 1970-01-01
        • 2014-02-16
        • 1970-01-01
        • 1970-01-01
        • 2011-02-03
        • 2022-01-18
        • 2021-05-18
        相关资源
        最近更新 更多