Created
May 29, 2025 14:57
-
-
Save kagg-design/11e520895121d251cfac48b71c244579 to your computer and use it in GitHub Desktop.
html_entity_decode_deep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Decode HTML entities in a string. | |
* Do it cycle to decode all possible entities, including cases like `<`. | |
* | |
* @since 1.9.2.3 | |
* | |
* @param string $html HTML. | |
* @param int $flags Flags. | |
* @param string|null $encoding Encoding. | |
* | |
* @return string | |
* @noinspection PhpMissingParamTypeInspection | |
*/ | |
function wpforms_html_entity_decode_deep( string $html, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, $encoding = null ): string { | |
do { | |
$previous_html = $html; | |
$html = html_entity_decode( $html, $flags, $encoding ); | |
} while ( $html !== $previous_html ); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment