[prev in list] [next in list] [prev in thread] [next in thread]
List: php-windows
Subject: Re: Re: [PHP-WIN] Tables (might be OT)
From: "Bobo Wieland" <dev () elstudion ! com>
Date: 2003-03-30 13:46:06
[Download RAW message or body]
Thanks to all of you for helping me.
So far, the css-option - word-wrap:break-word; - is the best solution. But
it's worthless since it doesn't work in Mozilla... To bad... =(
The code (below and in previous mail) is great too, but doesn't work either.
It is only _words_ that are too long that needs to be wraped, the whole
sentence can be longer...
Thanks!
.bobo
----- Original Message -----
From: "Neil Smith" <neil@fresh-toast.uklinux.net>
To: <php-windows@lists.php.net>
Sent: Sunday, March 30, 2003 3:12 PM
Subject: Re: Re: [PHP-WIN] Tables (might be OT)
> Yeah - I use the code below, which I made to limit title length for news
> stories. The main advantage is it limits to specified width, but then
> *backtracks* to the last whitespace before that in the string, so you get
> whole words output followed by '...' :-)
>
>
> ===============================================
>
> // Title width limiter
>
> $titlelimit=50; // Number of characters to allow in a news title
subsection
> (narrow column)
>
> if (strlen($row->newstitle)<$titlelimit) {
>
$secvars["news_title"]=htmlspecialchars($row->newstitle);
> } else {
>
$limitedstring=substr($row->newstitle,0,$titlelimit);
> $lastspace=strrpos($limitedstring," ");
> if ($lastspace===false ||
$lastspace==$titlelimit) {
> // Theres no space to chop string on, or its at the last position : just
> limit string to substring
>
$secvars["news_title"]=htmlspecialchars($limitedstring)." ...";
> } else {
> // Found a space near end of the string, back off to last space found and
> add ellipsis
>
$secvars["news_title"]=htmlspecialchars(substr($limitedstring,0,$lastspace))
." ...";
> }
> }
> // End title width limiter
>
>
> ==================================
> Hope that's (obvious !) , Regards,
> Neil Smith.
>
> At 03:03 30/03/2003 +0000, you wrote:
> >Message-Id: <se859f2b.066@groupwise.puk.ac.za>
> >Date: Sat, 29 Mar 2003 13:27:00 +0200
> >From: "Kobus Myburgh" <ITBJDM@puknet.puk.ac.za>
> >To: <dev@elstudion.com>
> >Cc: <php-windows@lists.php.net>
> >Mime-Version: 1.0
> >Content-Type: text/plain; charset=US-ASCII
> >Subject: Re: [PHP-WIN] Tables (might be OT)
> >
> >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;
> > }
>
>
> --
> 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic