메뉴 건너뛰기

프로그램언어

조회 수 26546 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
엄청난 코드의 삽질과 검색결과 완벽하게 돌아 가는 wordwrap 함수를 찾았습니다.
여기 tip&tech 에서 wordwrap 에 관한 글은 다 읽었습니다만..
가장많이 쓰는 인코딩방식인 utf-8 에서는 다른분께서 만드신 함수는 다 깨져 버리더군요.
물론 다른 인코딩방식은 실험 안 해 봤습니다.

이 코드는 php.com 에 tjomi4 님께서 wordwrap() 함수 manual 에 덧붙인 글에 있었습니다.
그럼 잘 쓰시구요.. 즐 코딩..

// # usage: utf8_wordwrap("text",3,"
");
// # by tjomi4`, thanks to SiMM.
// # www.yeap.lv
// modified by DJang
public function utf8_wordwrap($str,$len,$what){

    $from=0;
    $str_length = preg_match_all('/[x00-x7FxC0-xFD]/', $str, $var_empty);
    $while_what = round($str_length / $len);
    while($i <= $while_what){
        $string = preg_replace('#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$from.'}'.
     '((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$len.'}).*#s',
     '$1',$str);
        $total .= $string.$what;
        $from = $from+$len;
        $i++;
    }
    return $total;
}

  1. jquery 이용 아이디 중복체크 실시간

    Date2014.04.12 Views20341
    Read More
  2. htmlentities <-> html_entity_decode (엔티티

    Date2014.04.12 Views30423
    Read More
  3. iframe 사용시 iframe의 높이가 내용의 높이만큼 자동으로 조절

    Date2014.04.12 Views21862
    Read More
  4. php 파일 다운로드 구현

    Date2014.04.12 Views21699
    Read More
  5. php한글체크를 위한 정규표현식

    Date2014.04.12 Views22458
    Read More
  6. PHP 로그인후 현재 페이지로 돌아오기 처리

    Date2014.04.12 Views22662
    Read More
  7. 한글줄바꾸기 또는 utf-8 wordwrap

    Date2014.04.12 Views26546
    Read More
  8. [PHP] POST 로 넘어온 모든 변수값 확인하기

    Date2015.03.25 Views23337
    Read More
  9. POST값 통째로 인코딩하기

    Date2015.04.06 Views21175
    Read More
  10. [PHP] 서버 운영하시는분 서버 꺼졌을때 메시지 띄우기

    Date2015.04.06 Views20324
    Read More
  11. 홈페이지 귀퉁이에 붙이는 공지창

    Date2015.04.06 Views25426
    Read More
  12. 문자열 붙이기

    Date2015.04.14 Views19353
    Read More
  13. PHP에서 조건문 처리

    Date2015.04.14 Views22038
    Read More
  14. 문자열 나누기

    Date2015.04.14 Views19681
    Read More
  15. 문자열 치환하기

    Date2015.04.14 Views20492
    Read More
  16. PHP 변수전달 GET, POST

    Date2015.04.14 Views26566
    Read More
  17. 접속 IP 검사

    Date2015.04.14 Views21871
    Read More
  18. MySQL DB 중복여부 검사하여 없는 것만 추가

    Date2015.04.14 Views20157
    Read More
  19. addslashes 함수의 필요성

    Date2015.04.14 Views24250
    Read More
  20. fopen 파일 열기

    Date2015.04.14 Views20297
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved