Currently, the method I use to truncate strings is: echo substr($message, 0, 30).\"..\";
echo substr($message, 0, 30).\"..\";
How do I show the dots only in the case that the string has been tr
You could do:
echo strlen($message) > 30 ? substr($message, 0, 30) . '..' : $mssage;
Basically, it's like (but shorter):
if (strlen($message) > 30) { echo substr($message, 0, 30) . ".."; } else { echo $message; }