huy333912
1/10/2018 - 3:33 AM

cut text

function cutText($text, $num = 20)
{
	$text = trim(strip_tags($text));
	if ($text) {
		$arr_text = explode(" ", $text);
		$arr_text_new = array();
		if (count($arr_text) > $num) {
			for ($i=0; $i < $num; $i++) { 
				$arr_text_new[$i] = $arr_text[$i];
			}
			$text = implode(" ", $arr_text_new);
		}
	}
	return $text;
}