Text Overflow

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
radar
Hero Member
Hero Member
Posts: 632
Joined: Thu Jun 17, 2004 12:37 am

Text Overflow

Post by radar »

I'm currently working on a personal side-project and I would like to know how to get a text box to keep its width without expanding itself because some idiot has not learnt how to use the space bar. I've also found this problem on killablogs if someone posts a long comment it would turn out to be something similar to

[img]http://www.frozenplague.net/img/phpspam.png[/img]

As you can see by this screenshot, it pushes the content over to the right and "defaces" the site. Is there a way to get the php to recognise that the word is too long to belong in the english language and insert a <br> somewhere? So instead of lollollollollollollollollollollollollollollollollollollollollol you would have

lollollollollollollollollollollollol
lollollollollollollollollollollollol
Vercz
Hero Member
Hero Member
Posts: 1915
Joined: Sun May 09, 2004 6:13 am

Text Overflow

Post by Vercz »

[color=\"green\"]well...if you can work out how to define $string properly <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' /> ..this should work <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' />

[code]<?
$Length = 5;
$string = \'blog_post\';

if(strlen($string) > $Length){
   preg_match(\'/[a-zA-Z0-9]{0,\'.$Length.\'}/\', $string, $t);
   $Output = $t . \'<br>\';
}
?>[/code] [/color]
Last edited by Vercz on Tue Feb 15, 2005 11:29 am, edited 1 time in total.
Image

Image
Scott
Administrator
Administrator
Posts: 1651
Joined: Sun Apr 25, 2004 1:08 pm

Text Overflow

Post by Scott »

[url=\"http://aidan.dotgeek.org/lib/?file=function.str_chop.php\"]Also useful[/url]
Post Reply

Return to “PHP &amp; MySQL”