Re: php solution to html problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux