Re: Tables (might be OT)

From: Date: Sat, 29 Mar 2003 11:32:53 +0000
Subject: Re: Tables (might be OT)
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-19185@lists.php.net to get a copy of this message
Hi, just one correction to Kobus' code: function myTruncate ($verylongstring, $length) { if (strlen($verylongstring) > $length) { $shorterstring = substr($verylongstring,0,$length-1) . "..."; } else { $shorterstring = $verylongstring; } return $shorterstring; } He was missing a "{", otherwise it was fine. -- Ben O'Neill "Kobus Myburgh" <ITBJDM@puknet.puk.ac.za> wrote in message news:se859f2b.066@groupwise.puk.ac.za... 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@elstudion.com> 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

« previous php.windows (#19185) next »