Heim  >  Artikel  >  Backend-Entwicklung  >  PHP 数组字符集编码转换的函数

PHP 数组字符集编码转换的函数

WBOY
WBOYOriginal
2016-07-25 08:55:33956Durchsuche
  1. /**
  2. * 数组转编码
  3. * @param array $array 待转码数组
  4. * @param String $inCharset 原编码
  5. * @param String $outCharset 转换后的编码
  6. * @return $array 转换后的数组
  7. * @site:bbs.it-home.org
  8. */
  9. private function arrayCoding ($array, $inCharset, $outCharset) {
  10. if (!is_array($array))
  11. return false;
  12. foreach ($array as $key => &$value) {
  13. if (is_array($value)) {
  14. $value = $this->arrayCoding($value, $inCharset, $outCharset);
  15. } else {
  16. $value = iconv($inCharset, $outCharset, $value);
  17. }
  18. }
  19. return $array;
  20. }
复制代码

>>> 更多php数组编码转换的文章,请参考: php编码转换函数(自动转换字符集支持数组转换) php 对象转换数组与数组转换对象的例子(图文) php 自动检测内容编码并转换的代码 php中数组编码转换的方法 php数组编码转换的方法参考 学习php字符串编码的转换与判断



Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn