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... Link to comment https://forums.phpfreaks.com/topic/104958-solved-news/ 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. Link to comment https://forums.phpfreaks.com/topic/104958-solved-news/#findComment-537261 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 Link to comment https://forums.phpfreaks.com/topic/104958-solved-news/#findComment-537334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.