Skip to content

Instantly share code, notes, and snippets.

@lakinmohapatra
Created July 5, 2019 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lakinmohapatra/183962316478277d8f418bad517242f4 to your computer and use it in GitHub Desktop.
Save lakinmohapatra/183962316478277d8f418bad517242f4 to your computer and use it in GitHub Desktop.
Utf encode deep nested array
/**
* 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