dachshund Posted June 7, 2009 Share Posted June 7, 2009 hey, does anyone know how to use php to limit the text to only filling the cell without stretching it? for example if it looks like this at the moment then how do i make the text fill up to the bottom of the cell? at the moment I have to make a separate row in my mysql in which i type the cut down content that goes there myself. let me know if you can help. thanks Quote Link to comment https://forums.phpfreaks.com/topic/161260-solved-stop-the-text-at-the-end-of-the-cell/ Share on other sites More sharing options...
Daniel0 Posted June 7, 2009 Share Posted June 7, 2009 Use a combination of strlen and substr to truncate it. $text = 'bla bla bla'; if (strlen($text) > 100) { $text = substr($text, 0, 97) . '...'; } That will ensure that $text never becomes longer than 100 characters (including the trailing dots). Quote Link to comment https://forums.phpfreaks.com/topic/161260-solved-stop-the-text-at-the-end-of-the-cell/#findComment-850949 Share on other sites More sharing options...
dachshund Posted June 7, 2009 Author Share Posted June 7, 2009 ok cool, i understand now. one last thing, how do i set the $text or the 'bla bla bla' to be <? echo $rows['condensedcontent']; ?> ? Quote Link to comment https://forums.phpfreaks.com/topic/161260-solved-stop-the-text-at-the-end-of-the-cell/#findComment-851120 Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 Are you serious? You would set it to $row['condensedcontent'], and after the if statement Daniel0 posted, you do echo $text. Quote Link to comment https://forums.phpfreaks.com/topic/161260-solved-stop-the-text-at-the-end-of-the-cell/#findComment-851123 Share on other sites More sharing options...
dachshund Posted June 7, 2009 Author Share Posted June 7, 2009 ok thanks got it, sorry i did think that was it but it wasn't working before because of another error i had. all fixed, cheers. Quote Link to comment https://forums.phpfreaks.com/topic/161260-solved-stop-the-text-at-the-end-of-the-cell/#findComment-851129 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.