Re: string effect
| From: | Greg Donald | Date: | Fri, 29 Feb 2008 21:02:50 +0000 |
| Subject: | Re: string effect | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-270774@lists.php.net to get a copy of this message | ||
On 2/29/08, Alain Roger <raf.news@gmail.com> wrote:
> Hi,
>
> since a long time now, i see that some paragraphs of text are cut off and
> the additional text is replaced by 3 dots.
> e.g:
>
> "this is the original long text but without any sense and also stupid"
>
> effect desired :
> "this is the original long text..."
>
> this is usually used for title articles or some long paragraphs.
> What is the basic rule ?
> Text is cut off based on (numbers of words, number of characters,..) ?
> what is the algorithm for such thing ?
>
> thanks a lot,
function truncate( $string, $length=384, $ending='...' )
{
if( strlen( $string ) > $length )
$string = substr( $string, 0, $length ) . $ending ;
return $string;
}
--
Greg Donald
http://destiney.com/