Contents

조회 수 20363 댓글 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. [php] substr() 한글 자를 때 깨짐 방지

    Date2014.01.09 CategoryDevelop Byhooni Views20363
    Read More
  2. [ios] UIWebView 쿠키 유지

    Date2014.01.16 CategoryDevelop Byhooni Views11706
    Read More
  3. [ios] UIWebView에서 NSURLRequest에 Cookie 실어 보내기

    Date2014.01.16 CategoryDevelop Byhooni Views14859
    Read More
  4. [linux] CentOS 6.x Cati 설치 (yum)

    Date2014.01.17 CategorySystem/OS Byhooni Views48594
    Read More
  5. [js] 주소표시줄 URL 읽어오기 (변경까지)

    Date2014.01.21 CategoryDevelop Byhooni Views1
    Read More
  6. [ios] 네트워크 인디케이터(NetworkActivityIndicator) 작동

    Date2014.01.24 CategoryDevelop Byhooni Views12490
    Read More
  7. [ios] iOS 6.0 이상 회전 하기 (이전 버전과 비교 변경 부분)

    Date2014.01.27 CategoryDevelop Byhooni Views34185
    Read More
  8. [ios] NSString 간단한 정규식 사용법

    Date2014.01.28 CategoryDevelop Byhooni Views18220
    Read More
  9. [c] 64bit 머신에서 inet_ntoa() 사용시 Segment fault 대처 방법법

    Date2014.02.08 CategoryDevelop Byhooni Views14233
    Read More
  10. [php] XE 관리자 IP대역 설정 오류 해결법

    Date2014.02.10 CategoryDevelop Byhooni Views10775
    Read More
  11. [sql] 쿼리로 문자열 검색해서 일괄 치환하기

    Date2014.02.13 CategoryDatabase Byhooni Views9970
    Read More
  12. [html] SVG(Scalable Vector Graphics) 간단 정리

    Date2014.02.13 CategoryDevelop Byhooni Views8831
    Read More
Board Pagination Prev 1 ... 66 67 68 69 70 71 72 73 74 75 ... 98 Next
/ 98