This article mainly introduces the PHP custom function to transform the HTML tag method, combined with the instance form analysis PHP code conversion and regular replacement operation skills for the string, the need for friends can refer to the following
The example in this article describes how PHP custom functions convert HTML tags. Share to everyone for your reference, as follows:
<?php/** Created on 2016-9-29**/$orig = "I/ll \" Walk\ "the <b>dog</b> now"; $a = htmlentities ($orig); $b = HT Ml_entity_decode ($a); Echo $a; I ' ll "walk" The <b>dog</b> Nowecho $b; I ' ll "walk" the <b>dog</b> now//for users prior to PHP 4.3.0 you could do this:function unhtmlentities ($stri NG) { //Replace numeric entities $string = preg_replace (' ~& #x ([0-9a-f]+); ~ei ', ' Chr (Hexdec ("\\1")) ', $ string); $string = Preg_replace (' ~&# ([0-9]+); ~e ', ' Chr ("\\1") ', $string); Replace literal entities $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?>
The results of the operation are as follows: