Skip to content

Instantly share code, notes, and snippets.

@renie
Created March 28, 2012 20:59
Show Gist options
  • Save renie/2230445 to your computer and use it in GitHub Desktop.
Save renie/2230445 to your computer and use it in GitHub Desktop.
All array values to UTF8 ( recursive, so it works on assiciative array )
function convertArrayToUtf8(array $array) {
$convertedArray = array();
foreach($array as $key => $value) {
if(gettype($key)=='string')
$key = utf8_encode($key);
if(is_array($value))
$value = $this->convertArrayToUtf8($value);
if(gettype($value)=='string')
$convertedArray[$key] = utf8_encode($value);
else
$convertedArray[$key] = $value;
}
return $convertedArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment