Re: PHP Tokenize a String by its length
- From: Geoff Berrow <blthecat@xxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 11:10:55 +0000
Message-ID: <HWstf.630$i%4.305@trndny08> from Lüpher Cypher contained
the following:
>Shorter :)
>
>function trancate($string,$length) {
> $string = substr(trim($string),0,$length);
> $string = substr($string,0,strrpos(trim($string)," "));
> return "$string...";
>}
You don't need the last trim()
$string = substr($string,0,strrpos($string," "));
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
.
- Follow-Ups:
- Re: PHP Tokenize a String by its length
- From: Lüpher Cypher
- Re: PHP Tokenize a String by its length
- References:
- PHP Tokenize a String by its length
- From: Mavenos
- Re: PHP Tokenize a String by its length
- From: Geoff Berrow
- Re: PHP Tokenize a String by its length
- From: Lüpher Cypher
- PHP Tokenize a String by its length
- Prev by Date: Re: PHP Tokenize a String by its length
- Next by Date: Re: PHP Tokenize a String by its length
- Previous by thread: Re: PHP Tokenize a String by its length
- Next by thread: Re: PHP Tokenize a String by its length
- Index(es):
Relevant Pages
|