Home > Backend Development > PHP Tutorial > PHP 如何将Unicode编码转换为中文字符

PHP 如何将Unicode编码转换为中文字符

WBOY
Release: 2016-06-13 13:17:17
Original
1478 people have browsed it

PHP 怎么将Unicode编码转换为中文字符
网页显示是中文,但查看源码是下面这样的unicode编码

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->【GNIOUS】短袖情侣T恤 大城小爱4-时间印记-玫红 -----点击图片上的圈框,直接购买此宝贝-------
Copy after login


请问PHP怎么将这样代码转为中文汉字?因为要调用这些汉字做搜索字符串

------解决方案--------------------
$s = 【GNIOUS】短袖情侣T恤 大城小爱4-时间印记-玫红 -----点击图片上的圈框,直接购买此宝贝
CODE;

function foo($v) {
return iconv('ucs-2', 'gbk', pack('n', $v[1]));
}

echo preg_replace_callback('/(\d+);/', 'foo', $s);

【GNIOUS】短袖情侣T恤 大城小爱4-时间印记-玫红 -----点击图片上的圈框,直接购买此宝贝
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template