PDA

View Full Version : PHP Truncate Text


energylevel
08-10-2005, 04:00 AM
Can anyone tell me how truncate PHP dynamic text in Dreamweaver MX 2004 ??

Thanks.........

ranjan
08-10-2005, 04:32 AM
<?php

function trunc($phrase, $max_words)
{
$phrase_array = explode(' ',$phrase);
if(count($phrase_array) > $max_words && $max_words > 0)
$phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...'
return $phrase;
}
?>