echoninja Posted March 1, 2006 Share Posted March 1, 2006 I have been trying to find a tutorial on how to display the first X words from a database entry, like google does with search "..."'s[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]PHP: Hypertext PreprocessorPHP is a server-side HTML embedded scripting language. It provides web developerswith a full suite of tools for building dynamic websites: native APIs to ...[/quote]How can this be acheived? Link to comment https://forums.phpfreaks.com/topic/3805-displaying-first-x-words-from-database/ Share on other sites More sharing options...
rawb Posted March 1, 2006 Share Posted March 1, 2006 Feel free to copy/paste.function trimString($str, $newlength) { if (strlen($str) > $newlength) { $newlengthwithdots = $newlength - 3; $newstring = substr($str, 0, $newlengthwithdots); $newstring .= "..."; } else { $newstring = $str; }return $newstring;}*edit*Sorry if the indent is confusing, I'm not sure how to indent on these forums. Link to comment https://forums.phpfreaks.com/topic/3805-displaying-first-x-words-from-database/#findComment-13205 Share on other sites More sharing options...
echoninja Posted March 1, 2006 Author Share Posted March 1, 2006 great stuff, I can see how it works now :) thanks very much Link to comment https://forums.phpfreaks.com/topic/3805-displaying-first-x-words-from-database/#findComment-13208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.