Re: string effect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/29/08, Alain Roger <raf.news@xxxxxxxxx> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux