html_entity_decode — 모든 HTML 엔티티를 해당하는 문자로 변환 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

html_entity_decode — 모든 HTML 엔티티를 해당하는 문자로 변환 정보

PHP html_entity_decode — 모든 HTML 엔티티를 해당하는 문자로 변환

본문

html_entity_decode — 모든 HTML 엔티티를 해당하는 문자로 변환 

 

string html_entity_decode ( string $string [, int $quote_style [, string $charset ]] )

html_entity_decode()는 string의 모든 HTML 엔티티를 해당하는 문자로 변환합니다. htmlentities()의 역함수입니다.

 

<?php

$orig = "I'll \"walk\" the <b>dog</b> now";

 

$a = htmlentities($orig);

 

$b = html_entity_decode($a);

 

echo $a; // I'll "walk" the <b>dog</b> now

 

echo $b; // I'll "walk" the <b>dog</b> now

 

 

// PHP 4.3.0 이전 사용자는 이렇게 할 수 있습니다:

function unhtmlentities($string)

{

    // 숫자 엔티티 치환

    $string = preg_replace('~([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);

    // 문자 엔티티 치환

    $trans_tbl = get_html_translation_table(HTML_ENTITIES);

    $trans_tbl = array_flip($trans_tbl);

    return strtr($string, $trans_tbl);

}

 

$c = unhtmlentities($a);

 

echo $c; // I'll "walk" the <b>dog</b> now

 

?>

추천
0

댓글 0개

전체 577
개발자팁 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT