I have this code for the product description on the category page:
<?php echo substr($_product->getShortDescription(),0,40).'...'; ?>
But this code will show the ... always, even if the text length is 25 characters. How can I modify this code to show the ... only if the text is longer than 40 characters?