Ejemplo n.º 1
0
    static function limit_char_per_word($str = "", $limit = 10)
    {
        if (!EClassApi::countUpChars($str)) {
            $str = EClassApi::convertUnicodeCaseWithoutHtml($str);
        }

        $arr_tmp = explode(' ', $str);
        $str_tmp = '';
        foreach ($arr_tmp as $ar) {
            if (strlen($ar) > $limit) {
                $str_tmp .= ' ' . substr($ar, 0, $limit);
            } else {
                $str_tmp .= ' ' . $ar;
            }
        }

        return trim($str_tmp);
    }