Develop
2014.01.09 23:08
[php] substr() 한글 자를 때 깨짐 방지
Views 20440 Comment 0
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].'...'); }
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
1005 | Develop | [ios] How to set up clang formatter | hooni | 2015.09.17 | 1474 |
1004 | Etc |
ISMS 인증기준 – 정보보호대책 (시스템개발보안)
![]() |
hooni | 2016.12.01 | 1487 |
1003 | System/OS |
Configure Postfix to Use Gmail SMTP on Ubuntu 18.04
![]() |
hooni | 2020.02.07 | 1496 |
1002 | Etc |
모바일 프로그래머가 갖추어야 할 필수 역량
![]() |
hooni | 2017.02.16 | 1498 |
1001 | Develop | [ios] Swift 4 String, Date, DateFormatter 예제 | hooni | 2018.10.18 | 1513 |
1000 | System/OS |
RPA란? 어디에 어떻게 쓰이고 누가 만드나?
![]() |
hooni | 2020.01.28 | 1519 |
999 | Etc |
아이폰의 터치스크린 정확도
![]() |
hooni | 2015.04.01 | 1521 |
998 | System/OS |
How to Install and Use wget on Mac
![]() |
hooni | 2020.09.03 | 1540 |
997 | System/OS |
SSH Passwordless Login Using SSH Keygen in 5 Easy Steps
![]() |
hooni | 2019.11.22 | 1541 |
996 | Develop | What is difference between Get, Post, Put and Delete? | hooni | 2018.02.28 | 1571 |
995 | Develop | How to Test SMTP AUTH using Telnet | hooni | 2018.04.05 | 1590 |
994 | Develop |
[swift] popToRoot 모달뷰, 네비게이션컨트롤러 한꺼번에 닫기
![]() |
hooni | 2021.01.29 | 1599 |