...

View Full Version : add ... if longer than what is shown



BroChris
06-03-2004, 01:56 PM
<?php echo substr($category_topic_list[$i]["title"],0,20); ?>

If the title is longer than 20 characters, I'd like it to add "..." to the end to show that the title is longer than what is shown. Can this be done?

litebearer
06-03-2004, 03:33 PM
<?php
if (strlen($category_topic_list[$i]["title"]) > 20) {
echo substr($category_topic_list[$i]["title"],0,20) . "...";
} else {
echo $category_topic_list[$i]["title"];
}
?>

BroChris
06-03-2004, 03:34 PM
Makes perfect sense, don't know why I didn't think of that. Thank you so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum