How to force breaking of non breakable strings?

后端 未结 9 1063
-上瘾入骨i
-上瘾入骨i 2021-02-04 18:52

I have an HTML page that I generate from the data contained in a database. The database sometimes contains long strings that the browser can\'t break because the strings don\'t

9条回答
  •  梦谈多话
    2021-02-04 19:32

    The issue with using ­ and the solutions above is that an extra character is still there, and with a copy/paste action (even in plain text) it comes out.

    I would use instead the tag that is not visible and is not considered when copying.

    For example, to have email addresses break in two lines (only when there is not enough space) I use this:

    echo str_replace( "@","@", $email );
    

    That results in something like this:

    name.surname
    @website.com
    

提交回复
热议问题