Created
July 5, 2019 08:05
-
-
Save lakinmohapatra/183962316478277d8f418bad517242f4 to your computer and use it in GitHub Desktop.
Utf encode deep nested array
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
/** | |
* Converts array into utf8 | |
* | |
* @param Array $array | |
* @return Array | |
*/ | |
function utf8_converter($array) | |
{ | |
array_walk_recursive($array, function (&$item, $key) { | |
if (!mb_detect_encoding($item, 'utf-8', true)) { | |
$item = utf8_encode($item); | |
} | |
}); | |
return $array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment