function limit_char_per_word($str = "", $limit = 10) { if (!AZLib::countUpChars($str)) { $str = AZLib::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); }