Just found out PHP already has a multibyte truncate with
mb_strimwidth
— Get truncated string with specified width
It doesn’t obey word boundaries though. But handy nonetheless!
More Related Contents:
- Multi-byte safe wordwrap() function for UTF-8
- How do I check if a string contains a specific word?
- Split a comma-delimited string into an array?
- startsWith() and endsWith() functions in PHP
- PHP – concatenate or directly insert variables in string
- Why does PHP consider 0 to be equal to a string?
- Converting string to Date and DateTime
- Replacing accented characters php
- Capturing text between square brackets in PHP
- How do I remove all specific characters at the end of a string in PHP?
- Dollar ($) sign in password string treated as variable
- Replace last occurrence of a string in a string
- How can I check if a word is contained in another string using PHP?
- Converting a number (1, 2, 3) to a string (one, two, three) in PHP
- Remove a string from the beginning of a string
- What is the most efficient way to count all the occurrences of a specific character in a PHP string?
- How to get first x chars from a string, without cutting off the last word?
- How can I remove part of a string in PHP? [closed]
- Find first character that is different between two strings
- PHP String Manipulation: Extract hrefs
- How to convert PascalCase to snake_case?
- Get last whole number in a string
- Include constant in string without concatenating
- Remove Trailing Slash From String PHP
- Measure string size in Bytes in php
- Explode a paragraph into sentences in PHP
- How do I get the byte values of a string in PHP?
- How to validate that a string only contain lowercase letters?
- Regex to match an IP address [closed]
- How do I detect non-ASCII characters in a string?