Skip to content

[Funtion] 글자를 자르는 함수

MintState November 3, 2008 at 10:49 AM Views 11477

[Funtion] 글자를 자르는 함수

// 글자를 자르는 함수
function Cut_text($str,$max) {

		$string = stripslashes($str);           // 내용 

		$count = strlen($string); 
		
		if($count > $max) { //문자열의 길이가 10 보다 크면
			for ($pos=$max;$pos>0 && ord($string[$pos-1])>=127;$pos--); 
				if (($max-$pos)%2 == 0) { 
					$string = substr($string, 0, $max);
					$string = $string."...";
				} else { 
					$string = substr($string, 0, $max+1);
					$string = $string."...";
				}
			} 
		else { 
			$string = "$string"; 
		}
			
		return $string;
	}
Share X Facebook LINE QR code

0 comments

Be the first to comment.