shahzad Posted December 22, 2009 Share Posted December 22, 2009 $query_data['Comments']; i have one comments filed but what i want now is. if data is more than 1-2 lines or more than 100 characters end user with see only 2 lines and ... at the end so that he can click read more to view all. please help me with it. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/ Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 substr($string,0,300) for the first.. and are lines determined by line breaks or plain old text overflow? Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/#findComment-982349 Share on other sites More sharing options...
shahzad Posted December 22, 2009 Author Share Posted December 22, 2009 plain old text overflow Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/#findComment-982358 Share on other sites More sharing options...
shahzad Posted December 22, 2009 Author Share Posted December 22, 2009 thanks for you help.. but bye this substr($string,0,300) i get first 300 chars but now how to add 3 dots if there is more data.. if data is less then 300 then no need for dots. Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/#findComment-982359 Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 If its text overflow you cannot do it with PHP (as far as I know) Your best bet is to pick a max length that will look good in your layout and trim it down to fit nicely.. $max_len = 300; // Only show 300 characters // echo (strlen($string) > $max_len ? substr($string,0,$max_len).'...' : $string); will do the trick (UNTESTED) Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/#findComment-982362 Share on other sites More sharing options...
shahzad Posted December 23, 2009 Author Share Posted December 23, 2009 Thanks Thanks its working fine one more thing if i want to show full text once user clicks ... is it possible or not? Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/#findComment-982921 Share on other sites More sharing options...
trq Posted December 23, 2009 Share Posted December 23, 2009 Yes its possible. Make a link to a page that displays the full article. Link to comment https://forums.phpfreaks.com/topic/186028-i-want-to-echo-only-200-300-characters-or-1-2-lines-of-data-means/#findComment-982922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.