You are here: Re: [PHP] php solution to html problem « PHP « IT news, forums, messages
Re: [PHP] php solution to html problem

Posted by "Richard Lynch" on 08/25/05 11:26

On Wed, August 24, 2005 9:09 am, Ross wrote:
> I have a table which I put php data from a database.
>
> If i have a name 'thisisaveryverylongfirstname' the table stetches to
> fit
> the name. Is there any way I can force it to wrap to a fixed width of
> 100px??
>
> If I put a space in <BR> the text wraps. How can I do this at
> character 30
> of the string?
>
> Or any other suggestions...

PHP's wordwrap function may have an optional argument to FORCE it to
never be wider than X characters, but I don't think so...

You could write your own wordwrap function in about an hour, max.

Or take one of the umpteen wordwrap functions from before PHP had a
built-in wordwrap function.

If you are using CSS, and if you know the font and font-size it will
display in, I guess you could even fire up GD or PDF or something and
use the string length functions there with the same font and font-size
and figure out exactly where you should break up the string...

I'd cheat a little conservative if you REALLY need it to be no more
than 100px exactly, because I'm guessing differences in rendering will
make the text wider/narrower than GD thinks when the browser renders
it.

Actually, if you go to THAT much effort, and if it's really crucial,
maybe you should display the text as image. Ugh. Still, if it HAS to
be 100px or less, you could do that, and be CERTAIN of the width.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация