Contents

조회 수 20438 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
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. [web] 제로보드 XE 템플릿에서 if문에 대해서 알아봅시다

    Date2013.08.16 CategoryEtc Byhooni Views19915
    Read More
  2. [windows] 여러가지 활용 팁

    Date2003.04.23 CategorySystem/OS Byhooni Views20030
    Read More
  3. [c] AES 알고리즘 (암호화/복호화)

    Date2003.04.23 CategoryDevelop Byhooni Views20142
    Read More
  4. [c] UTF-8을 EUC-KR로 변환.. (iconv)

    Date2013.04.23 CategoryDevelop Byhooni Views20188
    Read More
  5. [ios] UIView에서 상위 UIViewController 가져오기

    Date2013.09.27 CategoryDevelop Byhooni Views20229
    Read More
  6. [linux] 꿀통(honeyd) 설치하기.. 메뉴얼 과정

    Date2006.04.23 CategorySystem/OS Byhooni Views20298
    Read More
  7. [php] substr() 한글 자를 때 깨짐 방지

    Date2014.01.09 CategoryDevelop Byhooni Views20438
    Read More
  8. [android] [번역] 안드로이드 Android Cloud to Device Messaging(C2DM)

    Date2013.04.23 CategoryDevelop Byhooni Views20480
    Read More
  9. [opengl] 컴퓨터 그래픽스 강의 자료(수업자료)

    Date2003.04.23 CategoryDevelop Byhooni Views20519
    Read More
  10. asx미디어 정보 기록..

    Date2003.04.23 CategorySystem/OS Byhooni Views20600
    Read More
  11. [c++] 디렉토리 내의 파일 찾기 FindFirstFile() 함수

    Date2013.04.23 CategoryDevelop Byhooni Views20647
    Read More
  12. git 브런치 배우기 (링크)

    Date2013.07.09 CategoryDevelop Byhooni Views20695
    Read More
Board Pagination Prev 1 ... 79 80 81 82 83 84 85 86 87 88 ... 98 Next
/ 98