Last active
January 15, 2016 21:53
-
-
Save marioangulo/94e84cf0ac314175d962 to your computer and use it in GitHub Desktop.
Decoding Items Encoded Multiple Times
This file contains 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
<?php | |
/** | |
* Loops through string to detect multiple encoding to be able to decode all levels. | |
* | |
* @param String $string | |
* The string you want to detect encoding on to be able to decode all its levels. | |
* | |
* @return String $string | |
* Clean decoded string. | |
*/ | |
function multiple_decoding($string = '') { | |
if(!empty($string)) { | |
while ($string !== html_entity_decode($string, ENT_QUOTES | ENT_HTML5, 'UTF-8')) { | |
$string = html_entity_decode($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); | |
} | |
return $string; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment