<?
function cut_text( $text, $maxwords = 10, $maxchar = 70 )
{
$sep=' ';
$sep2='...';
$words=preg_split("/[s,]+/", "$sep, $text"); // Оптимизировал :-) ENk
$char = iconv_strlen($text,'utf-8');
if (count($words) > $maxwords)
{
$text = join($sep, array_slice($words, 0, $maxwords));
}
if ( $char > $maxchar )
{
$text = iconv_substr( $text, 0, $maxchar, 'utf-8' );
}
return $text;
}
?>