How do you cut off text after a certain amount of characters in PHP?

前端 未结 11 1868
我在风中等你
我在风中等你 2021-02-02 12:22

I have two string that i want to limit to lets say the first 25 characters for example. Is there a way to cut off text after the 25th character and add a ... to the end of the s

11条回答
  •  被撕碎了的回忆
    2021-02-02 13:04

    http://php.net/manual/en/function.mb-strimwidth.php (PHP 4 >= 4.0.6, PHP 5, PHP 7)

    ";
    echo mb_strimwidth("Hello", 0, 10, "...");
    ?>
    

    output:

    Hello W...
    Hello
    

提交回复
热议问题