adam291086 Posted December 13, 2007 Share Posted December 13, 2007 Hello I want to create a caption from the text within my database. The text in the database is over 300 character and i want to display around 50. How do i go about doing thi Link to comment https://forums.phpfreaks.com/topic/81565-solved-limiting-the-amount-of-text-returned-from-mysql/ Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 Just display 50 of the 300 with PHP. Link to comment https://forums.phpfreaks.com/topic/81565-solved-limiting-the-amount-of-text-returned-from-mysql/#findComment-414203 Share on other sites More sharing options...
adam291086 Posted December 13, 2007 Author Share Posted December 13, 2007 this is it i dont know how, i have a basic search running on the database and returning the results. How do i limit the words? Link to comment https://forums.phpfreaks.com/topic/81565-solved-limiting-the-amount-of-text-returned-from-mysql/#findComment-414206 Share on other sites More sharing options...
themistral Posted December 13, 2007 Share Posted December 13, 2007 Have a look at the substr() PHP function - http://uk2.php.net/substr substr($string, 0, 50); should work for what you want! It will limit characters not words. Link to comment https://forums.phpfreaks.com/topic/81565-solved-limiting-the-amount-of-text-returned-from-mysql/#findComment-414207 Share on other sites More sharing options...
adam291086 Posted December 13, 2007 Author Share Posted December 13, 2007 is there away to add ............ on the end? Link to comment https://forums.phpfreaks.com/topic/81565-solved-limiting-the-amount-of-text-returned-from-mysql/#findComment-414218 Share on other sites More sharing options...
themistral Posted December 13, 2007 Share Posted December 13, 2007 echo substr($string, 0, 50) . '...'; Just add however many dots you want at the end after the substring. Link to comment https://forums.phpfreaks.com/topic/81565-solved-limiting-the-amount-of-text-returned-from-mysql/#findComment-414242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.