note 103956 modified in function.utf8-encode by danbrown
| From: | danbrown@php.net | Date: | Fri, 13 May 2011 15:26:43 +0000 |
| Subject: | note 103956 modified in function.utf8-encode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179693@lists.php.net to get a copy of this message | ||
My version for converting ISO array keys to utf8:
<?php
function convertArrayKeysToUtf8(array $array) {
$convertedArray = array();
foreach($array as $key => $value) {
if(!mb_check_encoding($key, 'UTF-8')) $key = utf8_encode($key);
if(is_array($value)) $value = $this->convertArrayKeysToUtf8($value);
$convertedArray[$key] = $value;
}
return $convertedArray;
}
?>
--was--
My version for converting ISO array keys to utf8:
function convertArrayKeysToUtf8(array $array) {
$convertedArray = array();
foreach($array as $key => $value) {
if(!mb_check_encoding($key, 'UTF-8')) $key = utf8_encode($key);
if(is_array($value)) $value = $this->convertArrayKeysToUtf8($value);
$convertedArray[$key] = $value;
}
return $convertedArray;
}
http://php.net/manual/en/function.utf8-encode.php