Re: selecting words

From: Date: Wed, 08 Aug 2001 13:43:13 +0000
Subject: Re: selecting words
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61824@lists.php.net to get a copy of this message
function TrimString($sString,$iLen=125){ $retstring=strtok($sString," ")." "; do { if(!$tmp=strtok(" ")." ") break; $retstring.=$tmp; } while(strlen($retstring)<$iLen); if(strlen($retstring)<strlen(trim($sString))) $retstring .="..."; return $retstring; } // end function Jamie Saunders wrote: > Hi, > > What I'd like to do is take a string (paragraph) of text consisting of say > 500 words and display only the first 100 words. Is there a function able to > do this? > > Thanks. > > Jamie

« previous php.general (#61824) next »