Re: PHP Tokenize a String by its length



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/
.



Relevant Pages

  • Re: Looking for very simple and dynamic photo gallery based on directories...
    ... Geoff Berrow (put thecat out to email) ... It's only Usenet, no one dies. ... My opinions, not the committee's, mine. ...
    (comp.lang.php)
  • Re: Encrypting PHP Code
    ... Geoff Berrow (put thecat out to email) ... It's only Usenet, no one dies. ... My opinions, not the committee's, mine. ...
    (comp.lang.php)
  • Re: bought a pole
    ... Geoff Berrow (put thecat out to email) ... It's only Usenet, no one dies. ... My opinions, not the committee's, mine. ...
    (uk.rec.walking)
  • Re: Todays walk (urw)
    ... Geoff Berrow (put thecat out to email) ... It's only Usenet, no one dies. ... My opinions, not the committee's, mine. ...
    (uk.rec.walking)
  • Re: Searching through an array
    ... Geoff Berrow (put thecat out to email) ... It's only Usenet, no one dies. ... My opinions, not the committee's, mine. ...
    (comp.lang.php)