<?php

function cut_text($text, $maxwords = 10, $maxchar = 30) {
    $sep = ' ';
    $words = @preg_split(" ", $text);
    $char = iconv_strlen($text, 'utf-8');
    if (count($words) > $maxwords) {
        $text = join($sep, array_slice($words, 0, $maxwords));
    }
    return $text;
}

