Home  >  Article  >  Backend Development  >  /* Process json_encode Chinese garbled characters */

/* Process json_encode Chinese garbled characters */

巴扎黑
巴扎黑Original
2016-11-29 11:40:481092browse

<?php
/* 处理json_encode中文乱码 */
$data = array (&#39;game&#39; => &#39;冰火国度&#39;, &#39;name&#39; => &#39;刺之灵&#39;, &#39;country&#39; => &#39;冰霜国&#39;, &#39;level&#39; => 45 );
echo json_encode ( $data );
echo "<br>";
$newData = array ();
foreach ( $data as $key => $value ) {
$newData [$key] = urlencode ( $value );
}
echo urldecode ( json_encode ( $newData ) );
?>

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