Contents

Views 20433 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
PHP의 substr() 함수를 쓸 때 한글이 깨지는 경우가 있다.
이런 경우 아래와 같은 함수로 대체하면 된다.

1. PHP 4.0 이상을 쓰면 mb_substr()을 이용
mb_substr($str, 0, 10, 'EUC-KR');
또는
mb_substr($str, 0, 10, 'UTF-8');

 
2. 그 외는 아래 함수를 작성해서 이용
function trim_str($str, $length) {
    if (!$str) return '';
    preg_match('/^([\xa1-\xfe]{2}|.){'.$length.'}/s', $str, $tmp_str);
    return (!$tmp_str[0]) ? $str : ($tmp_str[0].'...');
}


?

  1. [opengl] 컴퓨터 그래픽스 강의 자료(수업자료)

    Date2003.04.23 CategoryDevelop Byhooni Views20511
    Read More
  2. [android] [번역] 안드로이드 Android Cloud to Device Messaging(C2DM)

    Date2013.04.23 CategoryDevelop Byhooni Views20471
    Read More
  3. [php] substr() 한글 자를 때 깨짐 방지

    Date2014.01.09 CategoryDevelop Byhooni Views20433
    Read More
  4. [ios] UIView에서 상위 UIViewController 가져오기

    Date2013.09.27 CategoryDevelop Byhooni Views20210
    Read More
  5. [c] UTF-8을 EUC-KR로 변환.. (iconv)

    Date2013.04.23 CategoryDevelop Byhooni Views20173
    Read More
  6. [c] AES 알고리즘 (암호화/복호화)

    Date2003.04.23 CategoryDevelop Byhooni Views20117
    Read More
  7. [php] XE 에서 php 구문 사용하기 (XE 템플릿에서)

    Date2013.10.31 CategoryDevelop Byhooni Views19528
    Read More
  8. [js]모바일 웹에서 orientationchange

    Date2013.04.23 CategoryDevelop Byhooni Views19419
    Read More
  9. 모터에 대한 pid 제어.. ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views18929
    Read More
  10. URI 인코딩, URL 인코딩

    Date2013.04.23 CategoryDevelop Byhooni Views18894
    Read More
  11. [ios] Objective-C에서 형식이 있는 문자열(Format Strings)에 사용할 수 있는 토큰들(Tokens)

    Date2013.04.23 CategoryDevelop Byhooni Views18819
    Read More
  12. [ios] libxml/tree.h file not found

    Date2013.08.08 CategoryDevelop Byhooni Views18763
    Read More
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 ... 71 Next
/ 71