Home  >  Article  >  Backend Development  >  PHP array character set encoding conversion function

PHP array character set encoding conversion function

WBOY
WBOYOriginal
2016-07-25 08:55:33956browse
  1. /**
  2. * Array to encoding
  3. * @param array $array Array to be converted
  4. * @param String $inCharset Original encoding
  5. * @param String $outCharset Converted encoding
  6. * @return $array Converted 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. }
Copy code

>>> For more articles on PHP array encoding conversion, please refer to: php encoding conversion function (automatic character set conversion supports array conversion) Examples of php object conversion to array and array conversion to object (picture and text) php automatically detects content encoding and converts code Method of array encoding conversion in php PHP array encoding conversion method reference Learn the conversion and judgment of PHP string encoding



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn