php-windows | 2003032
Date: 03/29/03
- Next message: Ben O'Neill: "Re: [PHP-WIN] Tables (might be OT)"
- Previous message: Bobo Wieland: "[PHP-WIN] Tables (might be OT)"
- Maybe in reply to: Bobo Wieland: "[PHP-WIN] Tables (might be OT)"
- Next in thread: Ben O'Neill: "Re: [PHP-WIN] Tables (might be OT)"
- Reply: Ben O'Neill: "Re: [PHP-WIN] Tables (might be OT)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I have done a similar thing that worked reasonably well in Visual Basic (however, included is a PHP snippet which might do the trick - I am not a PHP pro).
write a small PHP function to select only a part of the string, say the first 15 characters, and append "..." to the string, for example,
thisisoneveryveryveryveryverylongword!!!!
will become:
thisisoneveryver...
This is standard PHP string manipulation, which might look something like this:
function myTruncate ($verylongstring, $length) {
if (strlen($verylongstring) > $length) {
$shorterstring = substr($verylongstring,0,$length-1) . "...";
}
else
$shorterstring = $verylongstring;
}
return $shorterstring;
}
(This is untested, but should work...).
You can then call this in your table cell as follows:
<td>print myTruncate("thisisoneveryveryveryveryverylongword!!!!", 15);</td>
Hope this helps :)
Regards,
Kobus
>>> "Bobo Wieland" <dev <email protected>> 3/29/2003 12:37:02 PM >>>
When using dynamic content, like PHP interacting with MySQL it is easier to
use tables then anything else. But tables will get you into trouble! If
someone enters a really long word the tablecell will expand so that the
hwole word will be shown.
Is there some way I can prevent this? With html, php or css? I've tried
style='overflow:hidden' but it didn't work...
.bobo
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Ben O'Neill: "Re: [PHP-WIN] Tables (might be OT)"
- Previous message: Bobo Wieland: "[PHP-WIN] Tables (might be OT)"
- Maybe in reply to: Bobo Wieland: "[PHP-WIN] Tables (might be OT)"
- Next in thread: Ben O'Neill: "Re: [PHP-WIN] Tables (might be OT)"
- Reply: Ben O'Neill: "Re: [PHP-WIN] Tables (might be OT)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

