cut text after (x) amount of characters

Posted by Blackbird on Stack Overflow See other posts from Stack Overflow or by Blackbird
Published on 2010-04-26T21:52:00Z Indexed on 2010/04/26 21:53 UTC
Read the original article Hit count: 108

Filed under:
|

This is in wordpress (not sure that makes a difference)

This bit of php outputs the post title

<?php echo $data['nameofpost']; ?>

It's simple text which can be anywhere up to 100 chars long. What i'd like is if the chars outputted are over 20 long to display '...' or simply nothing at all.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress