Smarter word-wrap in PHP for long words?

前端 未结 5 1490
無奈伤痛
無奈伤痛 2020-12-05 18:53

I\'m looking for a way to make word-wrap in PHP a bit smarter. So it doesn\'t pre-break long words leaving any prior small words alone on one line.

Let\'s say I have

5条回答
  •  感动是毒
    2020-12-05 19:41

    This should do the trick...

    $word = "hello!" . wordwrap('heeeeeeeeeeeeeeereisaverylongword', 25, '
    ', true); echo $word;

提交回复
热议问题