1The PHP way of doing this is simple:
2
3$out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;
4But you can achieve a much nicer effect with this CSS:
5
6.ellipsis {
7 overflow: hidden;
8 white-space: nowrap;
9 text-overflow: ellipsis;
10}
11Now, assuming the element has a fixed width, the browser will automatically break off and add the ... for you.