How to make him click more than the word limit?
The following is the illusion I wrote:
<code>mb_substr("1234567890",0,5,"utf-8");echo '...'; </code>
It will become 12345 at this time...no problem
But it will also display dots when it is not exceeded
<code>mb_substr("1234567890",0,15,"utf-8");echo '...'; </code>
1234567890...
The mb_substr function I checked online only introduces how to display the specified number of words
But I didn’t find how to set the conditions... it just clicks a little bit more than the number of displayed words I set
How to make him click more than the word limit?
The following is the illusion I wrote:
<code>mb_substr("1234567890",0,5,"utf-8");echo '...'; </code>
It will become 12345 at this time...no problem
But it will also display dots when it does not exceed
<code>mb_substr("1234567890",0,15,"utf-8");echo '...'; </code>
1234567890...
The mb_substr function I checked online only introduces how to display the specified number of words
But I didn’t find how to set the conditions... it just clicks a little bit more than the number of displayed words I set
You can only make your own judgment
<code>function my_substr($str, $start = 0, $length = 0, $encoding = 'utf-8') { return (mb_strlen($str) >= ($length - $start)) ? (mb_substr($str, $start, $length, $encoding).'...') : $str; }</code>