unidox Posted May 10, 2008 Share Posted May 10, 2008 I have a news section, and I was wondering how I could shorten the message so the user has to click read more. Like: Hi, This is news numb... Quote Link to comment Share on other sites More sharing options...
peranha Posted May 10, 2008 Share Posted May 10, 2008 <?php // Function to abbreviate characters after search. function truncate($string, $max_chars = 60) { if(strlen($string) > $max_chars) { $string = substr($string, 0, $max_chars).'...'; } return $string; } ?> you could use that, it will shorten to 60 characters. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 10, 2008 Share Posted May 10, 2008 http://phpsnips.com/snippet.php?id=15 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.