Home > php教程 > php手册 > PHP正则实例:把字符串中的汉字替换为红色

PHP正则实例:把字符串中的汉字替换为红色

WBOY
Release: 2016-06-07 11:34:44
Original
1491 people have browsed it

PHP正则实例:把字符串中的汉字替换为红色
PHP里使用正则表达式的一个经典实例:把字符串中的汉字替换为红色!
如果我们要用PHP把字符串中的汉字替换为红色,那么就应该想到有俩个过程:
第一就是用正则提取到字符串中的汉字,第二才是给这些汉字加上样式,看下面的实例:
PHP正则实例:把字符串中的汉字替换为红色

$string="I Love 黑帽联盟www.heimaolianmeng.com";
echo preg_replace("/([\x80-\xff]+)/","\\1",$string);
?>

AD:真正免费,域名+虚机+企业邮箱=0元

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template