Log in

View Full Version : Putting ... at the end of a title (substr question)



qwikad.com
05-17-2013, 12:14 PM
I've shortened titles to 60 characters. How do I tell this code to show three dots ... at the end of a title if the that title is more than 60 characters long and show nothing if it is less?



<?php echo substr($row['adtitle'], 0, 60); ?>


Thank you.

Beverleyh
05-17-2013, 12:37 PM
Something like;
$title = $row['adtitle'];
if (strlen($title) > 60) {
$title = substr($title, 0, 60).'...';
}
echo $title;

qwikad.com
05-17-2013, 01:19 PM
Thank you. It's what I needed!