admin 管理员组

文章数量: 1087747

php 简转繁体,php 繁体字转化为简体字

1.php加载mbstring

extension=php_mbstring.dll

2.配置mbstring

[mbstring]

; language for internal character representation.

; .language

mbstring.language = Chinese

; internal/script encoding.

; Some encoding cannot work as internal encoding.

; (e.g. SJIS, BIG5, ISO-2022-*)

; .internal-encoding

mbstring.internal_encoding =UTF-8

; http input encoding.

; .http-input

mbstring.http_input = auto

; http output encoding. mb_output_handler must be

; registered as output buffer to function

; .http-output

mbstring.http_output = UTF-8

; enable automatic encoding translation according to

; mbstring.internal_encoding setting. Input chars are

; converted to internal encoding by setting this to On.

; Note: Do _not_ use automatic encoding translation for

; portable libs/applications.

; .encoding-translation

mbstring.encoding_translation = On

3.我的代码:

function fantigetjianti($str) {

$fantis = "";

include "fanti2jiantiData.php"; //加载繁体字数组

for ($i = 0; $i <= mb_strlen($str); $i++) {

$fanti = mb_substr($str, $i, 1);

$jianti = $fantiData[$fanti];

if (empty($jianti)) {

$jianti = $fanti;

}

$fantis .=$jianti;

}

return $fantis;

}

本文标签: php 简转繁体 php 繁体字转化为简体字