Is there a way to determine if it has reached the end of a string or not. Right now I'm using this PHP function
<?php echo substr('some text', 0, 7)?>
To limit the character number to be displayed. Now I would like to add "..." to the text but only if it's not the end of the string.
So when I have a text "Hello!" it would display the whole thing and if I have a text "Determine" it would not only display "Determi" but also adds this "..." like that "Determi...".
I've tried these ellipse and overflow ways but they didn't work for me.
Would something like this described above be possible?
You can achieve this with the built-in function mb_strimwidth
:
<?php
echo mb_strimwidth("some text", 0, 7, "...")
// output: "some te..."
?>