Extracting Substrings at Word Boundaries in PHP
When truncating strings, you often need to avoid cutting off in the middle of a word. The naive substr() approach will break words, so you need logic to backtrack to the previous word boundary. The problem Given a string like “ab cc dde ffg ff”, if you want a substring of maximum 7 characters starting…
