Trim headline to nearest word

后端 未结 6 1845
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 19:45

Say for example I have the following code:

My very long title

Another long title

If I wanted to

6条回答
  •  半阙折子戏
    2020-12-06 20:18

    See this question:

    function wrap($string, $limit) {
      $wstring = explode("\n", wordwrap($string, $limit, "\n") );
      return $wstring[0] . '...';
    }
    

    Edit: (including <= $limit check)

    
    

提交回复
热议问题