[Funtion] 글자를 자르는 함수
페이지 정보
작성자 MintState 댓글 0건 조회 10,654회 작성일 08-11-03 10:49본문
[Funtion] 글자를 자르는 함수
01 | // 글자를 자르는 함수 |
02 | function Cut_text( $str , $max ) { |
03 |
04 | $string = stripslashes ( $str ); // 내용 |
05 |
06 | $count = strlen ( $string ); |
07 | |
08 | if ( $count > $max ) { //문자열의 길이가 10 보다 크면 |
09 | for ( $pos = $max ; $pos >0 && ord( $string [ $pos -1])>=127; $pos --); |
10 | if (( $max - $pos )%2 == 0) { |
11 | $string = substr ( $string , 0, $max ); |
12 | $string = $string . "..." ; |
13 | } else { |
14 | $string = substr ( $string , 0, $max +1); |
15 | $string = $string . "..." ; |
16 | } |
17 | } |
18 | else { |
19 | $string = "$string" ; |
20 | } |
21 | |
22 | return $string ; |
23 | } |
|
댓글목록
등록된 댓글이 없습니다.