Skip to content

Instantly share code, notes, and snippets.

@marioangulo
Last active January 15, 2016 21:53
Show Gist options
  • Save marioangulo/94e84cf0ac314175d962 to your computer and use it in GitHub Desktop.
Save marioangulo/94e84cf0ac314175d962 to your computer and use it in GitHub Desktop.
Decoding Items Encoded Multiple Times
<?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