Currently, the method I use to truncate strings is: echo substr($message, 0, 30).\"..\";
How do I show the dots only in the case that the string has been tr
It should be noted that the strlen() function does not count characters, it counts bytes. If you are using UTF-8 encoding you may end up with 1 character that is counted as up to 4 bytes. The proper way to do this would be something like:
echo mb_strlen($message) > 30 ? mb_substr($message, 0, 30) . "..." : $message;