On 2/29/08, Alain Roger <[EMAIL PROTECTED]> 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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to