Last active
June 23, 2017 13:38
-
-
Save githubnando/b70f931a373d9a12cd921b3b220ec110 to your computer and use it in GitHub Desktop.
Recursively encode to UTF-8 a given 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
<?php | |
# Recursively encode to UTF-8 a given array | |
public function utf8(array $array) | |
{ | |
array_walk_recursive($array, function(&$item, $key) { | |
if(is_string($item) && ! 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