How to trim String based on Size php [duplicate]
-
08-04-2021 - |
Frage
Possible Duplicate:
PHP - cut a string after X characters
Is there a way to cut or trim a String based on a Specific Size.
Let say we have "Lorem Ipsum dolor" and we want to cut that String to fit exactly the width of 20 Px and add "..." to the end of the String.
As far i tried this : http://www.php.net/manual/en/function.imagettfbbox.php but hard to get result as a newbie at PHP .
Lösung
I think you shouldn't do this with PHP. Because Number of characters you can have inside 20px is depend on the Case of letters (Upper / Lower), language of the text, font, etc...
So you better try CSS.
Ex: text-overflow: ellipsis;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow